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]
Other format: [Raw text]

Critical ~__pool troubles (libstdc++/17937)


Hi everyone,

earlier today (exactly while I was looking more into Carlo message)
Michael sent me this testcase, distilled from KDE arts:

#include <string>
#include <list>
using namespace std;
static list<string> modulePath;
int main()
{
 modulePath.push_back("hallo");
 return 0;
}

Therefore, no special settings are needed (e.g., per_type_pools) to
show that something is still not ok with ~__pool. I'm attaching below
valgrind's output for a --enable-__cxa_atexit build (removing it
avoids, as expected, all the errors).

Frankly, I'm wondering whether we really, *really*, /really/ need to
explicitly deallocate the pools instead of demanding the work to the
OS: why the original SGI/HP allocator didn't do that?? Perhaps Matt
could help here??

Thanks in advance,
Paolo.
==21072== Memcheck, a memory error detector for x86-linux.
==21072== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==21072== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==21072== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==21072== For more details, rerun with: -v
==21072== 
==21072== Invalid read of size 4
==21072==    at 0x1B9A85C9: __gnu_cxx::__exchange_and_add(int volatile*, int) (atomicity.cc:41)
==21072==    by 0x804902C: __gnu_cxx::__mt_alloc_base<std::string>::destroy(std::string*) (in /home/paolo/Work/a.out)
==21072==    by 0x80492A8: std::_List_base<std::string, std::allocator<std::string> >::_M_clear() (in /home/paolo/Work/a.out)
==21072==    by 0x8049311: std::_List_base<std::string, std::allocator<std::string> >::~_List_base() (in /home/paolo/Work/a.out)
==21072==  Address 0x1BB52320 is 16 bytes inside a block of size 4080 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B9452E6: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:209)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid read of size 4
==21072==    at 0x1B98C6C5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:370)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==    by 0x804902C: __gnu_cxx::__mt_alloc_base<std::string>::destroy(std::string*) (in /home/paolo/Work/a.out)
==21072==    by 0x80492A8: std::_List_base<std::string, std::allocator<std::string> >::_M_clear() (in /home/paolo/Work/a.out)
==21072==  Address 0x1BB5231C is 12 bytes inside a block of size 4080 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B9452E6: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:209)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid read of size 2
==21072==    at 0x1B945810: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:226)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB5204C is 36 bytes inside a block of size 258 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B9452A2: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:217)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid read of size 4
==21072==    at 0x1B94591B: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:276)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB52188 is 40 bytes inside a block of size 100 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B945294: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:216)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid read of size 4
==21072==    at 0x1B945920: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:276)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB52268 is 0 bytes inside a block of size 4 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B945302: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:213)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid write of size 4
==21072==    at 0x1B945922: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:276)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB52310 is 0 bytes inside a block of size 4080 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B9452E6: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:209)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid read of size 4
==21072==    at 0x1B945924: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:277)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB52188 is 40 bytes inside a block of size 100 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B945294: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:216)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== Invalid write of size 4
==21072==    at 0x1B945926: __gnu_cxx::__pool<true>::_M_reclaim_block(char*, unsigned) (mt_allocator.cc:277)
==21072==    by 0x1B946213: __gnu_cxx::__mt_alloc<char, __gnu_cxx::__common_pool_policy<true> >::deallocate(char*, unsigned) (mt_allocator.h:710)
==21072==    by 0x1B98C6E5: std::string::_Rep::_M_destroy(std::allocator<char> const&) (basic_string.tcc:371)
==21072==    by 0x1B98E96A: std::string::~string() (basic_string.h:218)
==21072==  Address 0x1BB52268 is 0 bytes inside a block of size 4 free'd
==21072==    at 0x1B904616: operator delete(void*) (vg_replace_malloc.c:156)
==21072==    by 0x1B945302: __gnu_cxx::__pool<true>::~__pool() (mt_allocator.cc:213)
==21072==    by 0x1B9587CF: __tcf_0 (mt_allocator.h:448)
==21072==    by 0x1BA45B91: exit (exit.c:54)
==21072== 
==21072== ERROR SUMMARY: 9 errors from 8 contexts (suppressed: 17 from 1)
==21072== malloc/free: in use at exit: 0 bytes in 0 blocks.
==21072== malloc/free: 18 allocs, 18 frees, 8932 bytes allocated.
==21072== For a detailed leak analysis,  rerun with: --leak-check=yes
==21072== For counts of detected errors, rerun with: -v

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