Red Hat Bugzilla – Bug 857236
Incorrect "dead code" elimination in 4.7.0
Last modified: 2016-11-24 11:16:02 EST
Created attachment 612643 [details]
Description of problem:
gcc 4.7.0 incorrectly compiles the attached code. It removes the assignment to current_call_data at line 28. I suppose that some part of it is thinking that's dead code because of the other assignment at line 33. But it is not dead code, because pg_re_throw() is not declared "leaf" nor "nothrow" (and in fact, in the real postgresql code this is extracted from, it does do a longjmp).
What is truly bizarre is that if you remove the inclusion of perl.h, the error goes away. I don't know what perl.h might contain that would affect this.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. gcc -O1 -S -I/usr/lib64/perl5/CORE plperlbug.c
2. examine produced assembly code.
current_call_data is restored only in the non-longjmp path.
Should assign to current_call_data just before pg_re_throw call.
That is a glibc bug. While in setjmp.h the __sigsetjmp prototype is properly marked as non-leaf:
extern int __sigsetjmp (struct __jmp_buf_tag __env, int __savemask) __THROWNL;
in pthread.h it is incorrectly marked as leaf:
extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROW;
When pthread.h is fixed, the testcase works properly.
Ho ... no wonder I had a feeling of deja vu about this. Isn't this the same as bug #752905? How did that manage to sneak back in?
Because sigsetjmp is prototyped in two different places. Only one got fixed the first time around :(
Fixed in f17, f18 (and rawhide shortly). Build spinning.
glibc-2.16-14.fc18 has been submitted as an update for Fedora 18.
glibc-2.15-57.fc17 has been submitted as an update for Fedora 17.
glibc-2.16-15.fc18 has been submitted as an update for Fedora 18.
glibc-2.16-15.fc18 has been pushed to the Fedora 18 stable repository. If problems still persist, please make note of it in this bug report.
glibc-2.15-57.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.