Bug 857236 - Incorrect "dead code" elimination in 4.7.0
Incorrect "dead code" elimination in 4.7.0
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jeff Law
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2012-09-13 17:32 EDT by Tom Lane
Modified: 2016-11-24 11:16 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-09-14 13:55:05 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
plperlbug.c (643 bytes, text/plain)
2012-09-13 17:32 EDT, Tom Lane
no flags Details

  None (edit)
Description Tom Lane 2012-09-13 17:32:02 EDT
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):

How reproducible:

Steps to Reproduce:
1. gcc -O1 -S -I/usr/lib64/perl5/CORE plperlbug.c
2. examine produced assembly code.

Actual results:
current_call_data is restored only in the non-longjmp path.

Expected results:
Should assign to current_call_data just before pg_re_throw call.
Comment 1 Jakub Jelinek 2012-09-14 07:51:31 EDT
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[1], 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.
Comment 2 Tom Lane 2012-09-14 10:31:48 EDT
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?
Comment 3 Jeff Law 2012-09-14 10:34:57 EDT
Because sigsetjmp is prototyped in two different places.  Only one got fixed the first time around  :(
Comment 4 Jeff Law 2012-09-14 13:55:05 EDT
Fixed in f17, f18 (and rawhide shortly).  Build spinning.
Comment 5 Fedora Update System 2012-09-14 15:44:19 EDT
glibc-2.16-14.fc18 has been submitted as an update for Fedora 18.
Comment 6 Fedora Update System 2012-09-14 15:46:49 EDT
glibc-2.15-57.fc17 has been submitted as an update for Fedora 17.
Comment 7 Fedora Update System 2012-09-17 11:20:14 EDT
glibc-2.16-15.fc18 has been submitted as an update for Fedora 18.
Comment 8 Fedora Update System 2012-09-23 23:26:29 EDT
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.
Comment 9 Fedora Update System 2012-09-26 05:09:10 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.