From patchwork Fri Nov 8 16:48:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 289891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E62A42C00DE for ; Sat, 9 Nov 2013 03:49:42 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; q=dns; s= default; b=udvzXr5vD05hT+VJBLBFE7vXxL6z17tmbGZSAqrNtUuV4U3blvI8+ jbdxI32zw6OA03xQ4lB48ZczbK+2LiuoPmPxPGBR0M0raXMitp36LQNHAYii3eCq 9Tg+iABG5hy9ppWaEEyTRhCfM4fwDC3NQ8aGlH6wmUBPWWwvvKvCYI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:content-type:mime-version; s= default; bh=+tJ+2L1UlHDwvdMeJRQT7ElN25Q=; b=vFYmH+xwl7AtZLzTwzA/ XngrCIRipeUEe86UFRy4h8f3PZHqrQDKsNHQ0A95CkKwZ0pFcavu7He3goBU4Smo r+6jrKNMUztYrO7uqlNPh8paLNoafLGGgmN1H3oC+77uVdDI2ESX/J2XGusdW08x B9iuSmJLcek+1wl06lAxYLQ= Received: (qmail 19586 invoked by alias); 8 Nov 2013 16:48:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 19558 invoked by uid 89); 8 Nov 2013 16:48:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_40, RDNS_NONE, SPF_PASS, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mga14.intel.com Received: from Unknown (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Nov 2013 16:48:51 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 08 Nov 2013 08:48:43 -0800 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.19.9.34]) by AZSMGA002.ch.intel.com with ESMTP; 08 Nov 2013 08:48:43 -0800 Received: from fmsmsx101.amr.corp.intel.com ([169.254.1.24]) by FMSMSX103.amr.corp.intel.com ([169.254.3.173]) with mapi id 14.03.0123.003; Fri, 8 Nov 2013 08:48:43 -0800 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" Subject: Fix for PR 59039 Date: Fri, 8 Nov 2013 16:48:41 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hello Everyone, Attached, please find a patch that will fix a crash in a function in libcilkrts when optimization was turned on. The issue was that the longjump and setjmp were called in the same function. This patch should fix that issue. The change is not in the compiler side but only in the Cilk Library. If it is OK with everyone, I will check this in this afternoon. Thanks, Balaji V. Iyer. Index: libcilkrts/runtime/cilk_fiber-unix.cpp =================================================================== --- libcilkrts/runtime/cilk_fiber-unix.cpp (revision 204546) +++ libcilkrts/runtime/cilk_fiber-unix.cpp (working copy) @@ -44,24 +44,27 @@ #include #include +#include +#include +#include + +// You'd think that getting a defintion for alloca would be easy. But you'd +// be wrong. Here's a variant on what's recommended in the autoconf doc. I've +// remove the Windows portion since this is Unix-specific code. #if defined HAVE_ALLOCA_H -# include +# include #elif defined __GNUC__ -# define alloca __builtin_alloca +# define alloca __builtin_alloca #elif defined _AIX -# define alloca __alloca +# define alloca __alloca #else -# include -# ifdef __cplusplus +# include +# ifdef __cplusplus extern "C" -# endif +# endif void *alloca (size_t); #endif -#include -#include -#include - // MAP_ANON is deprecated on Linux, but seems to be required on Mac... #ifndef MAP_ANONYMOUS #define MAP_ANONYMOUS MAP_ANON @@ -163,8 +166,15 @@ __cilkrts_bug("Should not get here"); } -#pragma GCC push_options -#pragma GCC optimize ("-O0") +// GCC doesn't allow us to call __builtin_longjmp in the same function that +// calls __builtin_setjmp, so create a new function to house the call to +// __builtin_longjmp +static void __attribute__((noinline)) +do_cilk_longjmp(__CILK_JUMP_BUFFER jmpbuf) +{ + CILK_LONGJMP(jmpbuf); +} + NORETURN cilk_fiber_sysdep::run() { // Only fibers created from a pool have a proc method to run and execute. @@ -201,7 +211,11 @@ // switching to for any temporaries required for this run() // function. JMPBUF_SP(m_resume_jmpbuf) = m_stack_base - frame_size; - CILK_LONGJMP(m_resume_jmpbuf); + + // GCC doesn't allow us to call __builtin_longjmp in the same function + // that calls __builtin_setjmp, so it's been moved into it's own + // function that cannot be inlined. + do_cilk_longjmp(m_resume_jmpbuf); } // Note: our resetting of the stack pointer is valid only if the @@ -228,7 +242,6 @@ // User proc should never return. __cilkrts_bug("Should not get here"); } -#pragma GCC pop_options void cilk_fiber_sysdep::make_stack(size_t stack_size) { Index: libcilkrts/ChangeLog =================================================================== --- libcilkrts/ChangeLog (revision 204546) +++ libcilkrts/ChangeLog (working copy) @@ -1,3 +1,9 @@ +2013-11-08 Balaji V. Iyer + + PR c/59039 + * runtime/cilk_fiber-unix.cpp: Fixed a crash in run() function + when optimization is turned on. + 2013-11-04 Balaji V. Iyer PR bootstrap/58951