This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: USER: linuxthreads causes segfault



> Exactly how did you configure gcc when you built it?  If done as a
> separate step, exactly how did you configure libstdc++-v3 when you
> built it?

gcc and libstdc++ were built at the same time as follows

With libstdc++-2.90.8 installed in libstdc++ under gcc-2.95.2 (version 2 libstdc++ and libio removed as per instructions in HTML doc)

gcc-2.95.2/configure i686-pc-linux-gnu --prefix=/usr --enable-namespaces --enable-threads=posix

make bootstrap 


> In another e-mail in this thread, you also mentioned an issue with
> ld-linux.so.  Try compiling (and linking) on Linux with the following
> command:
> 
> $ g++ -pthread -static src.C

HEY this works!!

However 

g++ -pthread src.C

without the static causes a crash.



Here's a backtrace of the crash for the dynamically linked exe.

#0  0x401a612c in chunk_free (ar_ptr=0x4023ad60, p=0x804bd18) at malloc.c:3111
#1  0x401a5fba in __libc_free (mem=0x804bd20) at malloc.c:3023
#2  0x400e5677 in __builtin_vec_delete (ptr=0x804bd20)
    at ../../gcc/cp/new2.cc:62
#3  0x400a35a2 in std::basic_filebuf<char, std::char_traits<char> >::close (
    this=0x804b6d8) at ../../../../libstdc++/bits/fstream.tcc:149
#4  0x400d08d4 in std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf (this=0x804b6d8, __in_chrg=3)
    at ../../../../libstdc++/bits/std_fstream.h:87
#5  0x4008524f in std::ios_base::Init::~Init (this=0x4011ac98, __in_chrg=2)
    at ../../../../libstdc++/src/ios.cc:118
#6  0x400863a3 in __static_initialization_and_destruction_0 (__initialize_p=0, 
    __priority=65535) at ../../../../libstdc++/bits/std_iostream.h:55
#7  0x400863fd in global destructors keyed to std::ios_base::boolalpha ()
    at ../../../../libstdc++/src/ios.cc:278
#8  0x4007e934 in __do_global_dtors_aux () from /usr/lib/libstdc++.so.3
#9  0x400ed801 in ?? () from /usr/lib/libstdc++.so.3
#10 0x4000aef6 in _dl_fini () at dl-fini.c:40
#11 0x4016d25a in exit (status=0) at exit.c:57
#12 0x401649d1 in __libc_start_main () at ../sysdeps/generic/libc-start.c:92



About ld-linux

Every exe crashes on exit like this when linked against libpthread.
However, for trivial exes which don't actually use any symbols from libpthread, I can make them run OK by explicitly linking ld-linux.so BEFORE libpthread.

Eg.

g++ src.C /lib/ld-linux.so.2 -lpthread

this will run OK.

Makes me think that there is some symbol conflict among libstdc++, ld-linux and pthreads.
As pthreads and ld-linux exist quite happily in a C context I have to assume that the symbol is something in libstdc++.

For some exes this causes a different crash and a message is displayed about a bug in dl (sorry can't reproduce it right now).


Thanks to all for the help on this

Rich





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]