|
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 |