This is the mail archive of the libstdc++@gcc.gnu.org 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: Memory allocators / STL


Loren James Rittle <rittle@latour.rsch.comm.mot.com> writes:

> Could you do something more for me?
> 
> Run the program under gdb.  Set a breakpoint on pthread_mutex_lock.
> Tell me if it ever hits.  Then, make sure it gets hit when the back
> trace reveals that the program is indeed in container allocation code.
> 
> Also, report the output of ``ldd a.out''.  Do you have multiple copies
> of gcc 3.0.X installed?  All configured properly for threads?  Is the
> proper libstdc++.so being bound?

Yes I do have two copies of gcc 3.0.X but the other is much older, and
is not in my path. Here are the build details:

$ type g++
g++ is hashed (/usr/local/gcc-3.0-cvs/bin/g++)

$ g++ -v -pthread -g z.cc
Reading specs from /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs
Configured with: /home/pm/sw/gcc-3.0-cvs/gcc/configure --prefix=/usr/local/gcc-3.0-cvs --enable-languages=c++ : (reconfigured) /home/pm/sw/gcc-3.0-cvs/gcc/configure --prefix=/usr/local/gcc-3.0-cvs --enable-languages=c++ : (reconfigured) /home/pm/sw/gcc-3.0-cvs/gcc/configure --prefix=/usr/local/gcc-3.0-cvs --enable-languages=c++ : (reconfigured) /home/pm/sw/gcc-3.0-cvs/gcc/configure --prefix=/usr/local/gcc-3.0-cvs --enable-languages=c++ : (reconfigured)  : (reconfigured) /home/pm/sw/gcc-3.0-cvs/gcc/configure --prefix=/usr/local/gcc-3.0-cvs --enable-languages=c++ --enable-threads
Thread model: posix
gcc version 3.0.3 20011027 (prerelease)
 /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=3 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -D_REENTRANT z.cc -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase z.cc -g -version -o /tmp/cc8FwoxV.s
GNU CPP version 3.0.3 20011027 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.3 20011027 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 3.0.3 20011027 (prerelease).
ignoring nonexistent directory "/usr/local/gcc-3.0-cvs/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3.0-cvs/include/g++-v3
 /usr/local/gcc-3.0-cvs/include/g++-v3/i686-pc-linux-gnu
 /usr/local/gcc-3.0-cvs/include/g++-v3/backward
 /usr/local/include
 /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/include
 /usr/include
End of search list.
 as -V -Qy -o /tmp/ccBLGLKC.o /tmp/cc8FwoxV.s
GNU assembler version 2.11.90.0.24 (i386-linux) using BFD version 2.11.90.0.24
 /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtbegin.o -L/usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3 -L/usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/../../.. /tmp/ccBLGLKC.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/local/gcc-3.0-cvs/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/crtend.o /usr/lib/crtn.o

$ ldd a.out
        libstdc++.so.3 => /usr/local/gcc-3.0-cvs/lib/libstdc++.so.3 (0x40014000)
        libm.so.6 => /lib/libm.so.6 (0x4008f000)
        libgcc_s.so.1 => /usr/local/gcc-3.0-cvs/lib/libgcc_s.so.1 (0x400ac000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x400b4000)
        libc.so.6 => /lib/libc.so.6 (0x400c7000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

So the compiler/library look OK. Now for gdb

$ gdb a.out
GNU gdb 2001-07-25-cvs (MI_OUT)
Copyright 2001 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 "i686-pc-linux-gnu"...
(gdb) b main
Breakpoint 1 at 0x8049cb9: file z.cc, line 54.
(gdb) r
Starting program: /home/pm/a.out 
[New Thread 1024 (runnable)]
[Switching to Thread 1024 (runnable)]

Breakpoint 1, main () at z.cc:54
54	  mt_test();
(gdb) b pthread_mutex_lock 
Breakpoint 2 at 0x400ba849
(gdb) c
Continuing.

Breakpoint 2, 0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
(gdb) bt
#0  0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x400bab9f in pthread_atfork () from /lib/libpthread.so.0
#2  0x401158ea in _IO_file_xsputn () from /lib/libc.so.6
#3  0x40115a5c in _IO_file_xsputn () from /lib/libc.so.6
#4  0x4011602a in malloc () from /lib/libc.so.6
#5  0x400bb1cd in __pthread_initialize_manager () from /lib/libpthread.so.0
#6  0x400bb470 in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.0
#7  0x08049c54 in mt_test() () at z.cc:47
#8  0x08049cbe in main () at z.cc:54
#9  0x400dfa42 in __libc_start_main () from /lib/libc.so.6
(gdb) c
Continuing.
[New Thread 2049 (runnable)]
[New Thread 1026 (runnable)]
[New Thread 2051 (runnable)]
[New Thread 3076 (runnable)]
[Switching to Thread 1026 (runnable)]

Breakpoint 2, 0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
(gdb) bt
#0  0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x401169f1 in free () from /lib/libc.so.6
#2  0x0804c351 in std::__malloc_alloc_template<0>::deallocate(void*, unsigned)
    (__p=0x8051ab8)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:122
#3  0x0804bbad in std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (__p=0x8051ab8, __n=772)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:356
#4  0x0804b55e in std::simple_alloc<std::_Hashtable_node<std::pair<int const, std::string> >*, std::__default_alloc_template<true, 0> >::deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (__p=0x8051ab8, 
    __n=193) at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:188
#5  0x0804aca4 in std::_Vector_alloc_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string>, true>::_M_deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (this=0x8051dc0, 
    __p=0x8051ab8, __n=193)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:122
#6  0x0804a3ff in std::_Vector_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~_Vector_base() (
    __in_chrg=0xbf7ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:142
#7  0x0804a043 in std::vector<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~vector() (__in_chrg=0xbf7ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:258
#8  0x0804cfb2 in std::hashtable<std::pair<int const, std::string>, int, std::hash<int>, std::_Select1st<std::pair<int const, std::string> >, std::equal_to<int>, std::allocator<std::string> >::~hashtable() (__in_chrg=0xbf7ffd0c)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/ext/stl_hashtable.h:314
#9  0x0804cf41 in std::hash_map<int, std::string, std::hash<int>, std::equal_to<int>, std::allocator<std::string> >::~hash_map() (__in_chrg=0xbf7ffd0c)
    at z.cc:34
#10 0x08049bd7 in f (arg=0x0) at z.cc:36
#11 0x400b9c9f in pthread_start_thread () from /lib/libpthread.so.0
#12 0x400b9ce2 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb) c
Continuing.
[Switching to Thread 2051 (runnable)]

Breakpoint 2, 0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
(gdb) bt
#0  0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x401169f1 in free () from /lib/libc.so.6
#2  0x0804c351 in std::__malloc_alloc_template<0>::deallocate(void*, unsigned)
    (__p=0x8052048)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:122
#3  0x0804bbad in std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (__p=0x8052048, __n=772)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:356
#4  0x0804b55e in std::simple_alloc<std::_Hashtable_node<std::pair<int const, std::string> >*, std::__default_alloc_template<true, 0> >::deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (__p=0x8052048, 
    __n=193) at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:188
#5  0x0804aca4 in std::_Vector_alloc_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string>, true>::_M_deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (this=0x8051dd0, 
    __p=0x8052048, __n=193)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:122
#6  0x0804a3ff in std::_Vector_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~_Vector_base() (
    __in_chrg=0xbf5ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:142
#7  0x0804a043 in std::vector<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~vector() (__in_chrg=0xbf5ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:258
#8  0x0804cfb2 in std::hashtable<std::pair<int const, std::string>, int, std::hash<int>, std::_Select1st<std::pair<int const, std::string> >, std::equal_to<int>, std::allocator<std::string> >::~hashtable() (__in_chrg=0xbf5ffd0c)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/ext/stl_hashtable.h:314
#9  0x0804cf41 in std::hash_map<int, std::string, std::hash<int>, std::equal_to<int>, std::allocator<std::string> >::~hash_map() (__in_chrg=0xbf5ffd0c)
    at z.cc:34
#10 0x08049bd7 in f (arg=0x1) at z.cc:36
#11 0x400b9c9f in pthread_start_thread () from /lib/libpthread.so.0
#12 0x400b9ce2 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb) c
Continuing.
[New Thread 4101 (runnable)]

Breakpoint 2, 0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
(gdb) bt
#0  0x400ba849 in pthread_mutex_lock () from /lib/libpthread.so.0
#1  0x401169f1 in free () from /lib/libc.so.6
#2  0x0804c351 in std::__malloc_alloc_template<0>::deallocate(void*, unsigned)
    (__p=0x8052048)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:122
#3  0x0804bbad in std::__default_alloc_template<true, 0>::deallocate(void*, unsigned) (__p=0x8052048, __n=772)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:356
#4  0x0804b55e in std::simple_alloc<std::_Hashtable_node<std::pair<int const, std::string> >*, std::__default_alloc_template<true, 0> >::deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (__p=0x8052048, 
    __n=193) at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_alloc.h:188
#5  0x0804aca4 in std::_Vector_alloc_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string>, true>::_M_deallocate(std::_Hashtable_node<std::pair<int const, std::string> >**, unsigned) (this=0x8051de0, 
    __p=0x8052048, __n=193)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:122
#6  0x0804a3ff in std::_Vector_base<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~_Vector_base() (
    __in_chrg=0xbf5ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:142
#7  0x0804a043 in std::vector<std::_Hashtable_node<std::pair<int const, std::string> >*, std::allocator<std::string> >::~vector() (__in_chrg=0xbf5ffd10)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/bits/stl_vector.h:258
#8  0x0804cfb2 in std::hashtable<std::pair<int const, std::string>, int, std::hash<int>, std::_Select1st<std::pair<int const, std::string> >, std::equal_to<int>, std::allocator<std::string> >::~hashtable() (__in_chrg=0xbf5ffd0c)
    at /usr/local/gcc-3.0-cvs/include/g++-v3/ext/stl_hashtable.h:314
#9  0x0804cf41 in std::hash_map<int, std::string, std::hash<int>, std::equal_to<int>, std::allocator<std::string> >::~hash_map() (__in_chrg=0xbf5ffd0c)
    at z.cc:34
#10 0x08049bd7 in f (arg=0x1) at z.cc:36
#11 0x400b9c9f in pthread_start_thread () from /lib/libpthread.so.0
#12 0x400b9ce2 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb) q
The program is running.  Exit anyway? (y or n) y


Philip


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