Bug 857236

Summary: Incorrect "dead code" elimination in 4.7.0
Product: [Fedora] Fedora Reporter: Tom Lane <tgl>
Component: glibcAssignee: Jeff Law <law>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 17CC: fweimer, hhorak, jakub, law, pfrankli, schwab, spoyarek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-14 17:55:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
plperlbug.c none

Description Tom Lane 2012-09-13 21:32:02 UTC
Created attachment 612643 [details]
plperlbug.c

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):
gcc-4.7.0-5.fc17.x86_64
perl-devel-5.14.2-212.fc17.x86_64

How reproducible:
100%

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 11:51:31 UTC
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 14:31:48 UTC
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 14:34:57 UTC
Because sigsetjmp is prototyped in two different places.  Only one got fixed the first time around  :(

Comment 4 Jeff Law 2012-09-14 17:55:05 UTC
Fixed in f17, f18 (and rawhide shortly).  Build spinning.

Comment 5 Fedora Update System 2012-09-14 19:44:19 UTC
glibc-2.16-14.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/glibc-2.16-14.fc18

Comment 6 Fedora Update System 2012-09-14 19:46:49 UTC
glibc-2.15-57.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/glibc-2.15-57.fc17

Comment 7 Fedora Update System 2012-09-17 15:20:14 UTC
glibc-2.16-15.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/glibc-2.16-15.fc18

Comment 8 Fedora Update System 2012-09-24 03:26:29 UTC
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 09:09:10 UTC
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.