[Bug libstdc++/54296] using the object in the map to erase element from the map crashes

paolo.carlini at oracle dot com gcc-bugzilla@gcc.gnu.org
Sun Aug 26 12:31:00 GMT 2012


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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-08-26
     Ever Confirmed|0                           |1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-26 12:31:10 UTC ---
I can confirm the valgrind error:

==7930== Memcheck, a memory error detector
==7930== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==7930== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==7930== Command: ./a.out
==7930== 
i = 47
==7930== Invalid read of size 4
==7930==    at 0x40344C: std::equal_to<int>::operator()(int const&, int const&)
const (in /home/paolo/Work/a.out)
==7930==    by 0x402F6D: std::__detail::_Equal_helper<int, std::pair<int const,
A>, std::__detail::_Select1st, std::equal_to<int>, unsigned long,
false>::_S_equals(std::equal_to<int> const&, std::__detail::_Select1st const&,
int const&, unsigned long, std::__detail::_Hash_node<std::pair<int const, A>,
false>*) (in /home/paolo/Work/a.out)
==7930==    by 0x4027D5: std::__detail::_Hashtable_base<int, std::pair<int
const, A>, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>,
std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash,
std::__detail::_Hashtable_traits<false, false, true> >::_M_equals(int const&,
unsigned long, std::__detail::_Hash_node<std::pair<int const, A>, false>*)
const (in /home/paolo/Work/a.out)
==7930==    by 0x401D8C: std::_Hashtable<int, std::pair<int const, A>,
std::allocator<std::pair<int const, A> >, std::__detail::_Select1st,
std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing,
std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy,
std::__detail::_Hashtable_traits<false, false, true> >::erase(int const&) (in
/home/paolo/Work/a.out)
==7930==    by 0x400EB6: main (in /home/paolo/Work/a.out)
==7930==  Address 0x5d6130c is 12 bytes inside a block of size 16 free'd
==7930==    at 0x4C285BC: operator delete(void*) (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==7930==    by 0x402D85:
__gnu_cxx::new_allocator<std::__detail::_Hash_node<std::pair<int const, A>,
false> >::deallocate(std::__detail::_Hash_node<std::pair<int const, A>,
false>*, unsigned long) (in /home/paolo/Work/a.out)
==7930==    by 0x402756: std::_Hashtable<int, std::pair<int const, A>,
std::allocator<std::pair<int const, A> >, std::__detail::_Select1st,
std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing,
std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy,
std::__detail::_Hashtable_traits<false, false, true>
>::_M_deallocate_node(std::__detail::_Hash_node<std::pair<int const, A>,
false>*) (in /home/paolo/Work/a.out)
==7930==    by 0x401D29: std::_Hashtable<int, std::pair<int const, A>,
std::allocator<std::pair<int const, A> >, std::__detail::_Select1st,
std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing,
std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy,
std::__detail::_Hashtable_traits<false, false, true> >::erase(int const&) (in
/home/paolo/Work/a.out)
==7930==    by 0x400EB6: main (in /home/paolo/Work/a.out)
==7930== 
==7930== 
==7930== HEAP SUMMARY:
==7930==     in use at exit: 0 bytes in 0 blocks
==7930==   total heap usage: 55 allocs, 55 frees, 1,488 bytes allocated
==7930== 
==7930== All heap blocks were freed -- no leaks are possible
==7930== 
==7930== For counts of detected and suppressed errors, rerun with: -v
==7930== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6)



More information about the Gcc-bugs mailing list