Bug 199788 - segmentation fault throwing exception from g++ app compiled -static
Summary: segmentation fault throwing exception from g++ app compiled -static
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: binutils (Show other bugs)
(Show other bugs)
Version: 3.0
Hardware: x86_64 Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-07-21 23:46 UTC by Matt Bonner
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-03-20 16:29:35 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Sample code to reproduce segfault (375 bytes, text/plain)
2006-07-21 23:46 UTC, Matt Bonner
no flags Details

Description Matt Bonner 2006-07-21 23:46:31 UTC
Description of problem:

I get a segfault compiling a simple C++ program with -static under the following
conditions:

. x86_64 cpu (Opteron 254)
. compile with -static switch
. program includes a call to gethostbyaddr
. program throws an exception that should be caught

This does not crash on 32-bit machines running WS3.

Version-Release number of selected component (if applicable):

RedHat WS3 Taroon 7
g++ 3.2.3
standard binutils or version 
glibc 2.3.2-95.39
How reproducible:


Steps to Reproduce:
1. Compile attachment on Opteron with g++ -static -o ts throwseg.cpp
2. run ./ts


Actual results:

observe segfault with backtrace like:

$ gdb ts core
Program received signal SIGSEGV, Segmentation fault.
0x0000000000442f2e in get_cie_encoding ()
(gdb) bt
#0  0x0000000000442f2e in get_cie_encoding ()
#1  0x000000000044335a in classify_object_over_fdes ()
#2  0x0000000000443fd2 in init_object ()
#3  0x00000000004438b2 in search_object ()
#4  0x0000000000443936 in _Unwind_Find_registered_FDE ()
#5  0x0000000000443d49 in _Unwind_Find_FDE ()
#6  0x0000000000441b45 in uw_frame_state_for ()
#7  0x00000000004420b7 in uw_init_context_1 ()
#8  0x0000000000442332 in _Unwind_RaiseException ()
#9  0x0000000000434646 in __cxa_throw ()
#10 0x00000000004002d5 in main ()

Expected results:

If the "ts" program ran to completion, it should output to stderr:

about to throw exception
compiling static, we never make it here

Additional info:

Works on 32-bit processors running WS3.

Comment 1 Matt Bonner 2006-07-21 23:46:31 UTC
Created attachment 132853 [details]
Sample code to reproduce segfault

Comment 2 Jakub Jelinek 2007-03-20 16:29:35 UTC
This is caused by a binutils bug, .eh_frame section isn't terminated in some
rare circumstances.  The fix is quite involved though and the benefits outweight
the risks this late in the RHEL3 development.
There is an easy workaround:
1) don't link static, it is almost always a bad choice, see
   http://people.redhat.com/drepper/no_static_linking.html
2) if after reading it you are still convinced you need to link something
   statically, to workaround this bug you can just link an empty function object
   after -lc, as in:
   echo 'void ehframe_dummy (void) { }' > ehframe_dummy.C
   g++ -static ... -lc ehframe_dummy.C
   (-lc ehframe_dummy.C added to whatever you had on your command line before)


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