After change #32012 we have seen test failures for our Linux builds as discussed by Jan here: http://groups.google.com/group/perl.perl5.porters/msg/ 7cea860c26fb4464 The failure also seem to be the same as one reported here: http://www.nntp.perl.org/group/perl.perl5.porters/2008/03/ msg134858.html What I've managed to figure out is that the problem is that gcc optimize out the return from the signal handler when the last statement in the function ends up being the call to S_raise_signal (). I found that this patch disable this optimization and make all tests pass again. Alternative fix is to compile the file mg.c with the -fno-optimize-sibling-calls option. --- perl-current/mg.c 2008-04-15 01:40:11.000000000 -0700 +++ perl-hack/mg.c 2008-04-23 10:37:44.000000000 -0700 @@ -1406,6 +1406,13 @@ #endif else S_raise_signal(aTHX_ sig); + + /* Segfaults observed when the call to S_raise_signal() is + * optimized into a jmp instead of a real call. An explicit + * return avoids this optimization. Alternative to compile + * this file with 'gcc -fno-optimize-sibling-calls' + */ + return; } #if defined(FAKE_PERSISTENT_SIGNAL_HANDLERS) || defined (FAKE_DEFAULT_SIGNAL_HANDLERS) I still don't understand why this ends up being problematic. Anybody able to explain it? Just seems to be something about how this optimization interacts how the stack is set up when the signal handler gets called. I found this message from somebody having a similar problem on NetBSD. http://gcc.gnu.org/ml/gcc/2006-03/msg00409.html BTW, this shows how the generated assembly code differs after the return statement has been added: --- xx1 2008-04-23 05:36:00.000000000 -0700 +++ xx2 2008-04-23 05:37:27.000000000 -0700 @@ -13,11 +13,11 @@ .LCFI190: .loc 1 1371 0 .LBB170: - movl PL_thr_key, %ecx + movl PL_thr_key, %eax .loc 1 1367 0 movl 8(%ebp), %ebx .loc 1 1371 0 - pushl %ecx + pushl %eax .LCFI191: call pthread_getspecific .loc 1 1389 0 @@ -38,24 +38,28 @@ je .L724 .L725: .loc 1 1403 0 - pushl %edx + pushl %eax pushl $0 pushl $0 pushl %ebx call *1180(%ecx) addl $16, %esp + .loc 1 1410 0 movl -4(%ebp), %ebx leave ret .p2align 4,,7 .L724: .loc 1 1408 0 - movl %ebx, 12(%ebp) - movl %ecx, 8(%ebp) + pushl %edx + pushl %edx + pushl %ebx + pushl %ecx + call S_raise_signal + addl $16, %esp movl -4(%ebp), %ebx leave -.LCFI192: - jmp S_raise_signal + ret .LBE170: .LFE113: .size Perl_csighandler, .-Perl_csighandlerThread Next