public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/35179]  New: execs crash in shared lib destructor = do_global_dtors_aux
@ 2008-02-13 15:06 lakshmivaraganm at hcl dot in
  2008-02-13 15:38 ` [Bug c++/35179] " lakshmivaraganm at hcl dot in
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: lakshmivaraganm at hcl dot in @ 2008-02-13 15:06 UTC (permalink / raw)
  To: gcc-bugs

+++ This bug was initially created as a clone of Bug #5925 +++
The same bug happens in gcc version 3.4.3 too:
Given below are the details:

The same problem is experienced in gcc version given below:

Reading specs from /VOBS/sol10tools/gcc/lib/gcc/i386-pc-solaris2.10/3.4.3/specs
Configured with: /root/tmp/gcc-3.4.3/configure --prefix=/VOBS/sol10tools/gcc
--with-as=/VOBS/sol10tools/gcc/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld
--without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)

Back trace:
~~~~~~~~~~~
#0  ~uppglob (this=0x827e220) at sysunixthreadcs.h:63
#1  0x080a6254 in __static_initialization_and_destruction_0 (__initialize_p=0,
__priority=0) at lax/main.cpp:27
#2  0x080924b7 in __do_global_dtors_aux ()
#3  0x08166685 in _fini () at iostream:77
#4  0xfd35126d in _exithandle () from /lib/libc.so.1
#5  0xfd343f22 in exit () from /lib/libc.so.1
#6  0x08092402 in _start ()

Regards,
Lax

Bug #5925 follows:
~~~~~~~~~~~~~~~~~~
We built a real simple test case.


When you run it, it crashes in __do_global_dtors_aux() on exit.
It only crashes when built on solaris-2.5.1 with 2.95.x; such execs crash on
all other (eg. solaris 2.6, 2.7) platforms.

Building with other gcc compiler versions on other platforms still works.

Building with a cygnus 2.9 compiler on Sol. 2.6, generates an exec that doesn't
crash on both 2.6 and 2.5.1; too bad we can't swith over to the other
environment!

Any hints as to what we are doing wrong?

Here is a transcript of my build and run:


[52]/mnt4/support/murf Yes, Master? make
gcc -o hellomain.o -c -g hellomain.c -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/cpp -lang-c -v
-D__GNUC__=2 -D__GNUC_MINOR__=95 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
-D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -g -D__GCC_NEW_VARARGS__ -Acpu(sparc)
-Amachine(sparc) hellomain.c /var/tmp/ccxbNhDY.i
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include

/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/../../../../sparc-sun-solaris2.5.1/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/../../../../include/g++-3
End of omitted list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/cc1 /var/tmp/ccxbNhDY.i
-quiet -dumpbase hellomain.c -g -version -o /var/tmp/ccixcsmS.s
GNU C version 2.95.2 19991024 (release) (sparc-sun-solaris2.5.1) compiled by
GNU C version 2.95.2 19991024 (release).
 /usr/local/sparc-sun-solaris2.5.1/bin/as -V -Qy -s -o hellomain.o
/var/tmp/ccixcsmS.s
GNU assembler version 2.11.2 (sparc-sun-solaris2.5.1) using BFD version 2.11.2
gcc -o hello_.o -g -c -fpic -DPIC hello.c -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/cpp -lang-c -v
-D__GNUC__=2 -D__GNUC_MINOR__=95 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4
-D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -g -D__GCC_NEW_VARARGS__ -Acpu(sparc)
-Amachine(sparc) -DPIC hello.c /var/tmp/ccgDKy5b.i
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include

/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/../../../../sparc-sun-solaris2.5.1/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/../../../../include/g++-3
End of omitted list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/cc1 /var/tmp/ccgDKy5b.i
-quiet -dumpbase hello.c -g -version -fpic -o /var/tmp/ccqcL1ah.s
GNU C version 2.95.2 19991024 (release) (sparc-sun-solaris2.5.1) compiled by
GNU C version 2.95.2 19991024 (release).
 /usr/local/sparc-sun-solaris2.5.1/bin/as -V -Qy -s -K PIC -o hello_.o
/var/tmp/ccqcL1ah.s
GNU assembler version 2.11.2 (sparc-sun-solaris2.5.1) using BFD version 2.11.2
gcc -o libhello.so -shared -g hello_.o -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/collect2 -V -G -dy -z
text -Y P,/usr/ccs/lib:/usr/lib -Qy -o libhello.so
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crti.o
/usr/ccs/lib/values-Xa.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtbegin.o
-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2
-L/usr/local/sparc-sun-solaris2.5.1/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/usr/local/lib hello_.o -lgcc -lgcc
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtend.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtn.o
GNU ld version 2.11.2 (with BFD 2.11.2)
  Supported emulations:
   elf32_sparc
gcc -g -o hello-exec hellomain.o -L. -lhello -v 
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/collect2 -V -Y
P,/usr/ccs/lib:/usr/lib -Qy -o hello-exec
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crt1.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crti.o
/usr/ccs/lib/values-Xa.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtbegin.o -L.
-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2
-L/usr/local/sparc-sun-solaris2.5.1/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/usr/local/lib hellomain.o -lhello -lgcc -lc -lgcc
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtend.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95.2/crtn.o
GNU ld version 2.11.2 (with BFD 2.11.2)
  Supported emulations:
   elf32_sparc
hello-exec
About to call hello!

Hello, World!
make: *** [hello-run] Segmentation Fault (core dumped)

[54]/mnt4/support/murf Yes, Master? gdb hello-exec
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.5.1"...
(gdb) run
Starting program: /mnt4/support/murf/hello-exec 
About to call hello!

Hello, World!

Program received signal SIGSEGV, Segmentation fault.
0xef7905d0 in __do_global_dtors_aux () from ./libhello.so
(gdb) where
#0  0xef7905d0 in __do_global_dtors_aux () from ./libhello.so
#1  0xef790750 in _fini () from ./libhello.so
#2  0xef7dba2c in ?? ()
#3  0xef69784c in _exithandle () from /usr/lib/libc.so.1
(gdb) quit

Release:
gcc-2.95.1,2,3

Environment:
Solaris-2.5.1
installed binutils=2.11.2

How-To-Repeat:
I've attached the test case. On a 2.5.1 system, run make.
It will build the .o's, the shared object, do the link, and run the exec.
If it can't find the .so, set the env LD_LIBRARY_PATH to .
Then re-run. You should die in the destructors.
Make sure you are on 2.5.1 of Solaris. Also, just tried 3.0 of gcc. Same crash.


-- 
           Summary: execs crash in shared lib destructor =
                    do_global_dtors_aux
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lakshmivaraganm at hcl dot in


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
@ 2008-02-13 15:38 ` lakshmivaraganm at hcl dot in
  2008-02-13 15:47 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: lakshmivaraganm at hcl dot in @ 2008-02-13 15:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from lakshmivaraganm at hcl dot in  2008-02-13 15:37 -------
The same problem is there in 3.4.6 version too:
Reading specs from /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
  2008-02-13 15:38 ` [Bug c++/35179] " lakshmivaraganm at hcl dot in
@ 2008-02-13 15:47 ` rguenth at gcc dot gnu dot org
  2008-02-13 16:59 ` [Bug target/35179] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-13 15:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2008-02-13 15:46 -------
Try a still maintained compiler which would be version 4.1.2 at least, and
specify the target you observe the bug.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
  2008-02-13 15:38 ` [Bug c++/35179] " lakshmivaraganm at hcl dot in
  2008-02-13 15:47 ` rguenth at gcc dot gnu dot org
@ 2008-02-13 16:59 ` pinskia at gcc dot gnu dot org
  2008-02-18 12:09 ` lakshmivaraganm at hcl dot in
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-13 16:59 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal
          Component|c++                         |target
 GCC target triplet|                            |i386-pc-solaris2.10


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
                   ` (2 preceding siblings ...)
  2008-02-13 16:59 ` [Bug target/35179] " pinskia at gcc dot gnu dot org
@ 2008-02-18 12:09 ` lakshmivaraganm at hcl dot in
  2009-05-31  1:53 ` radu dot gcc at ohmi dot org
  2009-05-31  1:55 ` radu dot gcc at ohmi dot org
  5 siblings, 0 replies; 7+ messages in thread
From: lakshmivaraganm at hcl dot in @ 2008-02-18 12:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from lakshmivaraganm at hcl dot in  2008-02-18 12:08 -------
This "Crash on exit" problem is there if we call exit(0) or call return 0.
If _exit(0) is used, there is no crash.


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
                   ` (3 preceding siblings ...)
  2008-02-18 12:09 ` lakshmivaraganm at hcl dot in
@ 2009-05-31  1:53 ` radu dot gcc at ohmi dot org
  2009-05-31  1:55 ` radu dot gcc at ohmi dot org
  5 siblings, 0 replies; 7+ messages in thread
From: radu dot gcc at ohmi dot org @ 2009-05-31  1:53 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug target/35179] execs crash in shared lib destructor = do_global_dtors_aux
  2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
                   ` (4 preceding siblings ...)
  2009-05-31  1:53 ` radu dot gcc at ohmi dot org
@ 2009-05-31  1:55 ` radu dot gcc at ohmi dot org
  5 siblings, 0 replies; 7+ messages in thread
From: radu dot gcc at ohmi dot org @ 2009-05-31  1:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from radu dot gcc at ohmi dot org  2009-05-31 01:55 -------
(From update of attachment 17939)
Works as expected:
gcc -g -o hello-exec hellomain.o -L. -lhello

Triggers the bug:
gcc -g -static -o hello-exec-gccbug35179 hellomain.o -shared -L. -lhello -v


-- 


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-05-31  1:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-13 15:06 [Bug c++/35179] New: execs crash in shared lib destructor = do_global_dtors_aux lakshmivaraganm at hcl dot in
2008-02-13 15:38 ` [Bug c++/35179] " lakshmivaraganm at hcl dot in
2008-02-13 15:47 ` rguenth at gcc dot gnu dot org
2008-02-13 16:59 ` [Bug target/35179] " pinskia at gcc dot gnu dot org
2008-02-18 12:09 ` lakshmivaraganm at hcl dot in
2009-05-31  1:53 ` radu dot gcc at ohmi dot org
2009-05-31  1:55 ` radu dot gcc at ohmi dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).