diff mbox

Compile libcilkrts with -funwind-tables (PR target/60290)

Message ID yddr3ej6lfc.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth April 6, 2016, 11:12 a.m. UTC
I've finally gotten around to analyzing this testsuite failure on 32-bit
Solaris/x86:

FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O1 -fcilkplus execution test
FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O3 -fcilkplus execution test
FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -O2 -fcilkplus execution test
FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -fcilkplus execution test

The testcase aborts like this:

Thread 2 received signal SIGABRT, Aborted.
[Switching to Thread 1 (LWP 1)]
0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
(gdb) where
#0  0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
#1  0xfe3b2d4f in thr_kill () from /lib/libc.so.1
#2  0xfe2f64da in raise () from /lib/libc.so.1
#3  0xfe2c93ee in abort () from /lib/libc.so.1
#4  0xfe525b37 in _Unwind_Resume (exc=0x80a75a0)
    at /vol/gcc/src/hg/trunk/local/libgcc/unwind.inc:234
#5  0xfe783b85 in __cilkrts_gcc_rethrow (sf=0xfeffdb00)
    at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/except-gcc.cpp:589
#6  0xfe77f0ea in __cilkrts_rethrow (sf=0xfeffdb00)
    at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/cilk-abi.c:548
#7  0x080513a3 in my_test ()
    at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:38
#8  0x080515bd in main ()
    at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:62

The gcc_assert in _Unwind_Resume triggers since
_Unwind_RaiseException_Phase2 returned _URC_FATAL_PHASE2_ERROR.  I found
that x86_fallback_frame_state had been invoked for this pc:

   0xfe77218e <__cilkrts_rethrow+30>:	add    $0x10,%esp

and returned _URC_END_OF_STACK, which is totally unexpected since
_Unwind_Find_FDE should have found it.  __cilkrts_rethrow is defined in
libcilkrts/cilk-abi.o, but in the 32-bit case EH info is missing:

32-bit:

ro@fuego 339 > elfdump -u .libs/libcilkrts.so|grep rethrow
       0x18def  0x3558c  __cilkrts_gcc_rethrow
  [0x11fc]      initloc:   0x18def [ sdata4 pcrel ]  __cilkrts_gcc_rethrow

64-bit:

ro@fuego 341 > elfdump -u amd64/libcilkrts/.libs/libcilkrts.so|grep rethrow
       0x1c639  0x2010  __cilkrts_rethrow
       0x2388b  0x5510  __cilkrts_gcc_rethrow
   [0x488]      initloc:   0x1c639 [ sdata4 pcrel ]  __cilkrts_rethrow
  [0x3988]      initloc:   0x2388b [ sdata4 pcrel ]  __cilkrts_gcc_rethrow

I traced this to -funwind-tables bein set on 32-bit Linux/x86, while it
is unset on 32-bit Solaris/x86  due to

i386/i386.c (ix86_option_override_internal):

      if (opts->x_flag_asynchronous_unwind_tables == 2)
	opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;

where i386/sol2.h has

#define USE_IX86_FRAME_POINTER 1

while the default is 0.

As expected, compiling libcilkrts with -funwind-tables (which is a no-op
on Linux/x86, Linux/x86_64, and Solaris/amd64) makes the failure go
away.

I'm uncertain if this is ok for mainline at this stage or has to wait
for gcc-7.  Once it goes into mainline, it's probably worth a backport
to all active release branches.

Thoughts?

	Rainer


2016-04-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR target/60290
	* Makefile.am (GENERAL_FLAGS): Add -funwind-tables.
	* Makefile.in: Regenerate.

Comments

Jeff Law April 22, 2016, 3:53 p.m. UTC | #1
On 04/06/2016 05:12 AM, Rainer Orth wrote:
> I've finally gotten around to analyzing this testsuite failure on 32-bit
> Solaris/x86:
>
> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O1 -fcilkplus execution test
> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O3 -fcilkplus execution test
> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -O2 -fcilkplus execution test
> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -fcilkplus execution test
>
> The testcase aborts like this:
>
> Thread 2 received signal SIGABRT, Aborted.
> [Switching to Thread 1 (LWP 1)]
> 0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
> (gdb) where
> #0  0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
> #1  0xfe3b2d4f in thr_kill () from /lib/libc.so.1
> #2  0xfe2f64da in raise () from /lib/libc.so.1
> #3  0xfe2c93ee in abort () from /lib/libc.so.1
> #4  0xfe525b37 in _Unwind_Resume (exc=0x80a75a0)
>      at /vol/gcc/src/hg/trunk/local/libgcc/unwind.inc:234
> #5  0xfe783b85 in __cilkrts_gcc_rethrow (sf=0xfeffdb00)
>      at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/except-gcc.cpp:589
> #6  0xfe77f0ea in __cilkrts_rethrow (sf=0xfeffdb00)
>      at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/cilk-abi.c:548
> #7  0x080513a3 in my_test ()
>      at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:38
> #8  0x080515bd in main ()
>      at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:62
>
> The gcc_assert in _Unwind_Resume triggers since
> _Unwind_RaiseException_Phase2 returned _URC_FATAL_PHASE2_ERROR.  I found
> that x86_fallback_frame_state had been invoked for this pc:
>
>     0xfe77218e <__cilkrts_rethrow+30>:	add    $0x10,%esp
>
> and returned _URC_END_OF_STACK, which is totally unexpected since
> _Unwind_Find_FDE should have found it.  __cilkrts_rethrow is defined in
> libcilkrts/cilk-abi.o, but in the 32-bit case EH info is missing:
>
> 32-bit:
>
> ro@fuego 339 > elfdump -u .libs/libcilkrts.so|grep rethrow
>         0x18def  0x3558c  __cilkrts_gcc_rethrow
>    [0x11fc]      initloc:   0x18def [ sdata4 pcrel ]  __cilkrts_gcc_rethrow
>
> 64-bit:
>
> ro@fuego 341 > elfdump -u amd64/libcilkrts/.libs/libcilkrts.so|grep rethrow
>         0x1c639  0x2010  __cilkrts_rethrow
>         0x2388b  0x5510  __cilkrts_gcc_rethrow
>     [0x488]      initloc:   0x1c639 [ sdata4 pcrel ]  __cilkrts_rethrow
>    [0x3988]      initloc:   0x2388b [ sdata4 pcrel ]  __cilkrts_gcc_rethrow
>
> I traced this to -funwind-tables bein set on 32-bit Linux/x86, while it
> is unset on 32-bit Solaris/x86  due to
>
> i386/i386.c (ix86_option_override_internal):
>
>        if (opts->x_flag_asynchronous_unwind_tables == 2)
> 	opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
>
> where i386/sol2.h has
>
> #define USE_IX86_FRAME_POINTER 1
>
> while the default is 0.
>
> As expected, compiling libcilkrts with -funwind-tables (which is a no-op
> on Linux/x86, Linux/x86_64, and Solaris/amd64) makes the failure go
> away.
>
> I'm uncertain if this is ok for mainline at this stage or has to wait
> for gcc-7.  Once it goes into mainline, it's probably worth a backport
> to all active release branches.
>
> Thoughts?
>
> 	Rainer
>
>
> 2016-04-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	PR target/60290
> 	* Makefile.am (GENERAL_FLAGS): Add -funwind-tables.
> 	* Makefile.in: Regenerate.
OK.  Thanks for tracking this down, including verification that the 
difference between Solaris and Linux is the latter having 
-funwind-tables on by default.

jeff
Rainer Orth April 26, 2016, 8:56 a.m. UTC | #2
Hi Jeff,

> On 04/06/2016 05:12 AM, Rainer Orth wrote:
>> I've finally gotten around to analyzing this testsuite failure on 32-bit
>> Solaris/x86:
>>
>> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O1 -fcilkplus execution test
>> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -O3 -fcilkplus execution test
>> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -O2 -fcilkplus execution test
>> FAIL: g++.dg/cilk-plus/CK/catch_exc.cc  -g -fcilkplus execution test
>>
>> The testcase aborts like this:
>>
>> Thread 2 received signal SIGABRT, Aborted.
>> [Switching to Thread 1 (LWP 1)]
>> 0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
>> (gdb) where
>> #0  0xfe3ba3c5 in __lwp_sigqueue () from /lib/libc.so.1
>> #1  0xfe3b2d4f in thr_kill () from /lib/libc.so.1
>> #2  0xfe2f64da in raise () from /lib/libc.so.1
>> #3  0xfe2c93ee in abort () from /lib/libc.so.1
>> #4  0xfe525b37 in _Unwind_Resume (exc=0x80a75a0)
>>      at /vol/gcc/src/hg/trunk/local/libgcc/unwind.inc:234
>> #5  0xfe783b85 in __cilkrts_gcc_rethrow (sf=0xfeffdb00)
>>      at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/except-gcc.cpp:589
>> #6  0xfe77f0ea in __cilkrts_rethrow (sf=0xfeffdb00)
>>      at /vol/gcc/src/hg/trunk/local/libcilkrts/runtime/cilk-abi.c:548
>> #7  0x080513a3 in my_test ()
>>      at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:38
>> #8  0x080515bd in main ()
>>      at /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc:62
>>
>> The gcc_assert in _Unwind_Resume triggers since
>> _Unwind_RaiseException_Phase2 returned _URC_FATAL_PHASE2_ERROR.  I found
>> that x86_fallback_frame_state had been invoked for this pc:
>>
>>     0xfe77218e <__cilkrts_rethrow+30>:	add    $0x10,%esp
>>
>> and returned _URC_END_OF_STACK, which is totally unexpected since
>> _Unwind_Find_FDE should have found it.  __cilkrts_rethrow is defined in
>> libcilkrts/cilk-abi.o, but in the 32-bit case EH info is missing:
>>
>> 32-bit:
>>
>> ro@fuego 339 > elfdump -u .libs/libcilkrts.so|grep rethrow
>>         0x18def  0x3558c  __cilkrts_gcc_rethrow
>>    [0x11fc]      initloc:   0x18def [ sdata4 pcrel ]  __cilkrts_gcc_rethrow
>>
>> 64-bit:
>>
>> ro@fuego 341 > elfdump -u amd64/libcilkrts/.libs/libcilkrts.so|grep rethrow
>>         0x1c639  0x2010  __cilkrts_rethrow
>>         0x2388b  0x5510  __cilkrts_gcc_rethrow
>>     [0x488]      initloc:   0x1c639 [ sdata4 pcrel ]  __cilkrts_rethrow
>>    [0x3988]      initloc:   0x2388b [ sdata4 pcrel ]  __cilkrts_gcc_rethrow
>>
>> I traced this to -funwind-tables bein set on 32-bit Linux/x86, while it
>> is unset on 32-bit Solaris/x86  due to
>>
>> i386/i386.c (ix86_option_override_internal):
>>
>>        if (opts->x_flag_asynchronous_unwind_tables == 2)
>> 	opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
>>
>> where i386/sol2.h has
>>
>> #define USE_IX86_FRAME_POINTER 1
>>
>> while the default is 0.
>>
>> As expected, compiling libcilkrts with -funwind-tables (which is a no-op
>> on Linux/x86, Linux/x86_64, and Solaris/amd64) makes the failure go
>> away.
>>
>> I'm uncertain if this is ok for mainline at this stage or has to wait
>> for gcc-7.  Once it goes into mainline, it's probably worth a backport
>> to all active release branches.
>>
>> Thoughts?
>>
>> 	Rainer
>>
>>
>> 2016-04-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>>
>> 	PR target/60290
>> 	* Makefile.am (GENERAL_FLAGS): Add -funwind-tables.
>> 	* Makefile.in: Regenerate.
> OK.  Thanks for tracking this down, including verification that the
> difference between Solaris and Linux is the latter having -funwind-tables
> on by default.

thanks, installed.  About eventual backports to the 5 and 6 (after 6.1
is released) and maybe even 4.9 branches?

	Rainer
Jakub Jelinek April 26, 2016, 8:58 a.m. UTC | #3
On Tue, Apr 26, 2016 at 10:56:16AM +0200, Rainer Orth wrote:
> > OK.  Thanks for tracking this down, including verification that the
> > difference between Solaris and Linux is the latter having -funwind-tables
> > on by default.
> 
> thanks, installed.  About eventual backports to the 5 and 6 (after 6.1
> is released) and maybe even 4.9 branches?

After a week or three on the trunk so that people have a chance to report
issues, yes.

	Jakub
diff mbox

Patch

# HG changeset patch
# Parent  5ffdfe8da23c38390b9520b92cb76f53dfc3da0b
Compile libcilkrts with -funwind-tables (PR target/60290)

diff --git a/libcilkrts/Makefile.am b/libcilkrts/Makefile.am
--- a/libcilkrts/Makefile.am
+++ b/libcilkrts/Makefile.am
@@ -43,6 +43,9 @@  GENERAL_FLAGS = -I$(top_srcdir)/include 
 # Enable Intel Cilk Plus extension
 GENERAL_FLAGS += -fcilkplus
 
+# Always generate unwind tables
+GENERAL_FLAGS += -funwind-tables
+
 AM_CFLAGS = $(XCFLAGS) $(GENERAL_FLAGS) -std=c99
 AM_CPPFLAGS = $(GENERAL_FLAGS)
 AM_LDFLAGS = $(XLDFLAGS)