[Bug target/35179] execs crash in shared lib destructor = do_global_dtors_aux

radu dot gcc at ohmi dot org gcc-bugzilla@gcc.gnu.org
Sun May 31 01:53:00 GMT 2009



------- Comment #5 from radu dot gcc at ohmi dot org  2009-05-31 01:52 -------
Created an attachment (id=17939)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17939&action=view)
Improved hello-test case showing working and failing command lines, with
Makefile

This behaviour exists on "Linux beam 2.6.22-15-server #1 SMP Wed Aug 20
19:08:24 UTC 2008 i686 GNU/Linux", running "gcc version 4.1.3 20080308
(prerelease) (Ubuntu 4.1.2-21ubuntu1)"

In my case, I found it accidentally, as there was a stray '-static' on the
command line, even though I was compiling a shared build. Removing '-static'
fixes the problem, but I did bang by head against the wall a couple of times
while looking for the problem.

The attached testcase shows how this bug is duplicated. It is the same testcase
submitted previously, but I added the '-static -shared' combo, as on my system
the original testcase did not reproduce the bug. The output from my run is:

gcc -o hellomain.o -c -g hellomain.c
hellomain.c: In function 'main':
hellomain.c:9: warning: incompatible implicit declaration of built-in function
'exit'
gcc -o hello_.o -g -c -fpic -DPIC hello.c
gcc -o libhello.so -shared -g hello_.o
gcc -g -o hello-exec hellomain.o -L. -lhello
echo Linking with both -static and -shared flags exposes the bug.
Linking with both -static and -shared flags exposes the bug.
gcc -g -static -o hello-exec-gccbug35179 hellomain.o -shared -L. -lhello -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.1.3 --program-suffix=-4.1
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.3 20080308 (prerelease) (Ubuntu 4.1.2-21ubuntu1)
 /usr/lib/gcc/i486-linux-gnu/4.1.3/collect2 -m elf_i386 --hash-style=both
-shared -o hello-exec-gccbug35179
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.1.3/crtbeginT.o -L.
-L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3
-L/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib -L/lib/../lib
-L/usr/lib/../lib hellomain.o -lhello --start-group -lgcc -lgcc_eh -lc
--end-group /usr/lib/gcc/i486-linux-gnu/4.1.3/crtendS.o
/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crtn.o
./hello-exec
About to call hello!

Hello, World!
gdb -x gdb.run ./hello-exec-gccbug35179
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...

Program received signal SIGSEGV, Segmentation fault.
0x80000426 in __do_global_dtors_aux ()
Current language:  auto; currently asm
The program is running.  Exit anyway? (y or n) [answered Y; input not from
terminal]


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35179



More information about the Gcc-bugs mailing list