|
From: sgromoll <sgr...@gr...> - 2006-06-20 14:17:01
|
Hi,
I am trying to use valgrind to debug a segfault. The program seems to be
crashing on a statement that declares an stl map:
map<int, float> type_to_a1;
cout << "OK" << endl;
map<int, float> type_to_a2; // CRASHES HERE
Valgrind reports no errors before this statement. When it segfaults,
valgrind reports:
==21379== Invalid read of size 4
==21379== at 0x1BE22632: std::__default_alloc_template<true,
0>::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==21379== by 0x1BB93FFE:
std::__simple_alloc<std::_Rb_tree_node<std::pair<int const, float> >,
std::__default_alloc_template<true, 0> >::allocate(unsigned)
(stl_alloc.h:232)
==21379== by 0x1BB93FC1: std::_Rb_tree_alloc_base<std::pair<int const,
float>, std::allocator<std::pair<int const, float> >, true>::_M_get_node()
(stl_tree.h:564)
==21379== by 0x1BB93F8C: std::_Rb_tree_base<std::pair<int const, float>,
std::allocator<std::pair<int const, float> >
>::_Rb_tree_base(std::allocator<std::pair<int const, float> > const&)
(stl_tree.h:579)
==21379== Address 0x4 is not stack'd, malloc'd or (recently) free'd
==21379==
==21379== Process terminating with default action of signal 11 (SIGSEGV)
==21379== Access not within mapped region at address 0x4
==21379== at 0x1BE22632: std::__default_alloc_template<true,
0>::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7)
==21379== by 0x1BB93FFE:
std::__simple_alloc<std::_Rb_tree_node<std::pair<int const, float> >,
std::__default_alloc_template<true, 0> >::allocate(unsigned)
(stl_alloc.h:232)
==21379== by 0x1BB93FC1: std::_Rb_tree_alloc_base<std::pair<int const,
float>, std::allocator<std::pair<int const, float> >, true>::_M_get_node()
(stl_tree.h:564)
==21379== by 0x1BB93F8C: std::_Rb_tree_base<std::pair<int const, float>,
std::allocator<std::pair<int const, float> >
>::_Rb_tree_base(std::allocator<std::pair<int const, float> > const&)
(stl_tree.h:579)
==21379==
==21379== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 36 from 2)
Is valgrind reporting an error in STL? it seems more likely that i am
corrupting memory but valgrind does not report any other errors before this.
I noticed in the FAQ that memcheck can't do bounds checking on static
arrays- is this a possible explanation?
thanks,
-stefan
--
View this message in context: http://www.nabble.com/memcheck-error-in-libstdc%2B%2B.so.5.0.7-t1817850.html#a4955850
Sent from the Valgrind - Users forum at Nabble.com.
|
|
From: Nicholas N. <nj...@cs...> - 2006-06-21 00:18:24
|
On Tue, 20 Jun 2006, sgromoll wrote: > I am trying to use valgrind to debug a segfault. The program seems to be > crashing on a statement that declares an stl map: > > map<int, float> type_to_a1; > cout << "OK" << endl; > map<int, float> type_to_a2; // CRASHES HERE > > Valgrind reports no errors before this statement. When it segfaults, > valgrind reports: > > ==21379== Invalid read of size 4 > ==21379== at 0x1BE22632: std::__default_alloc_template<true, > 0>::allocate(unsigned) (in /usr/lib/libstdc++.so.5.0.7) > [...] > ==21379== Address 0x4 is not stack'd, malloc'd or (recently) free'd > [...] > ==21379== Process terminating with default action of signal 11 (SIGSEGV) > ==21379== Access not within mapped region at address 0x4 > > Is valgrind reporting an error in STL? The problem is occurring in the STL but it may a bug in your code that is the root cause. > it seems more likely that i am > corrupting memory but valgrind does not report any other errors before this. > I noticed in the FAQ that memcheck can't do bounds checking on static > arrays- is this a possible explanation? No. Memcheck has told you exactly what the problem is: the program is using the value 0x4 as a pointer. It cannot tell you why your program doing this bad thing. You'll have to work that out. If it is a bug in the STL, that may be difficult. Nick |
|
From: Dennis L. <pla...@pr...> - 2006-06-21 10:39:40
|
What valgrind, compiler and OS version are you using? Am Dienstag, den 20.06.2006, 07:01 -0700 schrieb sgromoll: > Hi, > > I am trying to use valgrind to debug a segfault. The program seems to be > crashing on a statement that declares an stl map: > > map<int, float> type_to_a1; > cout << "OK" << endl; > map<int, float> type_to_a2; // CRASHES HERE > > Valgrind reports no errors before this statement. When it segfaults, > valgrind reports: PS: STL is something old from SGI&HP, since 1998 (since there is a C++ standard) there is a "C++ Standard Library" |