Dead Lock in singe threaded application

Carlo Wood carlo@alinoe.com
Tue Oct 2 18:51:00 GMT 2001


Hi, I did run into a dead lock with a single threaded application
and was wondering if the standard allows this dead lock or not.

The problem is most likely the fact that I am writing a C++
debugging library who uses 'string' and which redefines its
own malloc function.

I could start to use my own allocator<> :/, but I am worried
about this: I had to drop support for Multi-Threading for
per-3.0 because of a similar problem.  If more dead locks
like this are latent then in the end I'd not be allowed to
use libstdc++ at all in my library - which would be impossible
given the current state.

Here is the back trace of the dead lock.

(gdb) bt
#0  0x401dccc5 in __sigsuspend (set=0xbfffeb54) at ../sysdeps/unix/sysv/linux/sigsuspend.c:45
#1  0x400aa0a9 in __pthread_wait_for_restart_signal (self=0x400b2d80) at pthread.c:967
#2  0x400abd59 in __pthread_alt_lock (lock=0x8053990, self=0x0) at restart.h:34
#3  0x400a8c46 in __pthread_mutex_lock (mutex=0x8053980) at mutex.c:120
#4  0x080518d6 in std::__default_alloc_template<true, 0>::allocate(unsigned) (__n=51)
    at /usr/local/gcc-3.0.1/include/g++-v3/i686-pc-linux-gnu/bits/gthr-default.h:485
#5  0x08051832 in std::string::_Rep::_S_create(unsigned, std::allocator<char> const&) (__capacity=38, __alloc=@0xbfffed14)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:581
#6  0x40063669 in std::string::_M_mutate(unsigned, unsigned, unsigned) (this=0xbfffee44, __pos=0, __len1=0, __len2=38)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:572
#7  0x40061a17 in std::string& std::string::_M_replace<char const*>(std::__normal_iterator<char*, std::string>, std::__normal_iterator<char*, std::string>, char const*, char const*, std::forward_iterator_tag) (this=0xbfffee44, __i1=
      {<iterator<std::random_access_iterator_tag,char,int,char*,char&>> = {<No data fields>}, _M_current = 0x80561b8 ""}, __i2=
      {<iterator<std::random_access_iterator_tag,char,int,char*,char&>> = {<No data fields>}, _M_current = 0x80561b8 ""},
    __k1=0x40338018 "/tmp/31722-i386/BUILD/glibc-2.2.4/csu/", __k2=0x4033803e "")
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_iterator.h:251
#8  0x40032bf3 in libcw::debug::elf32::object_file_ct::load_stabs() (this=0x805a4d0)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/basic_string.h:645
#9  0x40033286 in libcw::debug::elf32::object_file_ct::find_nearest_line(libcw::debug::elf32::asymbol_st const*, unsigned, char const**, char const**, unsigned*) (this=0x805a4d0, symbol=0x8062f00, offset=134552267, file=0xbfffef3c, func=0xbffff060, line=0xbffff05c) at elf32.cc:1731
#10 0x4003b575 in libcw::debug::location_ct::M_pc_location(void const*, libcw::debug::_internal_::TSD_st&) (this=0xbffff054, addr=0x8051acb,
    __libcwd_tsd=@0x8056228) at bfd.cc:211
#11 0x40046ca6 in libcw::debug::internal_malloc(unsigned, libcw::debug::memblk_types_nt, void*, libcw::debug::_internal_::TSD_st&) (
    size=76552, flag=memblk_type_malloc, call_addr=0x8051acb, __libcwd_tsd=@0x8056228) at include/libcw/bfd.h:66
#12 0x4004fad6 in malloc (size=76552) at debugmalloc.cc:1962
#13 0x08051acc in std::__default_alloc_template<true, 0>::_S_chunk_alloc(unsigned, int&) (__size=32, __nobjs=@0xbffff13c)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:430
#14 0x0805196d in std::__default_alloc_template<true, 0>::_S_refill(unsigned) (__n=32)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:473
#15 0x080518ee in std::__default_alloc_template<true, 0>::allocate(unsigned) (__n=25)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:281
#16 0x08051832 in std::string::_Rep::_S_create(unsigned, std::allocator<char> const&) (__capacity=12, __alloc=@0xbffff1d4)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/stl_alloc.h:581
#17 0x080516b9 in std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned) (this=0x82a7a78, __alloc=@0xbffff1d4, __res=5)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/basic_string.tcc:389
#18 0x080522ec in std::string::reserve(unsigned) (this=0xbffff544, __res=12) at /usr/local/gcc-3.0.1/include/g++-v3/bits/basic_string.h:246
#19 0x40063095 in std::string::append(std::string const&) (this=0xbffff544, __str=@0xbffff4d4)
    at /usr/local/gcc-3.0.1/include/g++-v3/bits/basic_string.tcc:486
#20 0x40058621 in libcw::debug::(anonymous namespace)::demangler_ct::decode_unqualified_name(std::string&) (this=0xbffff4b4,
    output=@0xbffff544) at /usr/local/gcc-3.0.1/include/g++-v3/bits/basic_string.h:454
#21 0x40057ebc in libcw::debug::(anonymous namespace)::demangler_ct::decode_nested_name(std::string&, std::string&) (this=0xbffff4b4,
    output=@0xbffff544, qualifiers=@0xbffff344) at demangle3.cc:1507
#22 0x4005871a in libcw::debug::(anonymous namespace)::demangler_ct::decode_name(std::string&, std::string&) (this=0xbffff4b4,
    output=@0xbffff544, nested_name_qualifiers=@0xbffff344) at demangle3.cc:1695
#23 0x40054523 in libcw::debug::(anonymous namespace)::demangler_ct::decode_class_enum_type(std::string&) (this=0xbffff4b4,
    output=@0xbffff544) at demangle3.cc:414
#24 0x40057c0e in libcw::debug::(anonymous namespace)::demangler_ct::decode_type(std::string&, libcw::debug::(anonymous namespace)::qualifiers_ct*) (this=0xbffff4b4, output=@0xbffff544, qualifiers=0x8056dd0) at demangle3.cc:1413
#25 0x40059728 in libcw::debug::demangle_type(char const*, std::string&) (in=0x40077a20 "PPN5libcw5debug5elf3210asymbol_stE",
    output=@0xbffff544) at demangle3.cc:1946
#26 0x40059c70 in libcw::debug::_internal_::make_label(char const*) (mangled_name=0x40077a20 "PPN5libcw5debug5elf3210asymbol_stE")
    at type_info.cc:70
#27 0x4003ca52 in __static_initialization_and_destruction_0(int, int) (__initialize_p=1, __priority=65535) at include/libcw/type_info.h:40
#28 0x4003cd22 in _GLOBAL__I__ZN5libcw5debug5cwbfd13error_handlerEPKcz () at /usr/local/gcc-3.0.1/include/g++-v3/bits/codecvt.h:228
#29 0x40060a67 in __do_global_ctors_aux () at /usr/local/gcc-3.0.1/include/g++-v3/bits/locale_facets.h:97
#30 0x4002d6de in _init () at eval.c:41
#31 0x4000d947 in _dl_init () at eval.c:41

-- 
Carlo Wood <carlo@alinoe.com>



More information about the Libstdc++ mailing list