Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 199788 - segmentation fault throwing exception from g++ app compiled -static
segmentation fault throwing exception from g++ app compiled -static
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: binutils (Show other bugs)
x86_64 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2006-07-21 19:46 EDT by Matt Bonner
Modified: 2007-11-30 17:07 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-03-20 12:29:35 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
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 19:46 EDT, Matt Bonner
no flags Details

  None (edit)
Description Matt Bonner 2006-07-21 19:46:31 EDT
Description of problem:

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

. 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 19:46:31 EDT
Created attachment 132853 [details]
Sample code to reproduce segfault
Comment 2 Jakub Jelinek 2007-03-20 12:29:35 EDT
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
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.