|
From: Sahni, J. <jit...@cr...> - 2007-12-19 21:41:23
|
is there any way in memcheck to detect out of bound array access, when using stl objects like std::string and std::map ? Recently I had once such bug and took me about 10 days with valgrind before it pin pointed me to exact error line and I think reason for this may be because stl may be doing a bit of its own memory management . e.g when a string of say size 5 bytes is created and then destroyed, stl may request say 64 bytes from the heap and try to recycle that. I was thinking if there is an option to directly check stl array bounds so that the error can be caught sooner Jitan ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ============================================================================== |
|
From: Nicholas N. <nj...@cs...> - 2007-12-20 01:47:55
|
On Wed, 19 Dec 2007, Sahni, Jitan wrote: > is there any way in memcheck to detect out of bound array access, when > using stl objects like std::string and std::map ? Recently I had once such > bug and took me about 10 days with valgrind before it pin pointed me to > exact error line and I think reason for this may be because stl may be > doing a bit of its own memory management . e.g when a string of say size 5 > bytes is created and then destroyed, stl may request say 64 bytes from the > heap and try to recycle that. I was thinking if there is an option to > directly check stl array bounds so that the error can be caught sooner Memcheck will only detect such errors if the array edge happens to be at a heap block edge. It's an inherent limitation in Memcheck, one that's extremely difficult to avoid. Nick |
|
From: Paul P. <ppl...@gm...> - 2007-12-20 01:55:02
|
On Dec 19, 2007 1:39 PM, Sahni, Jitan <jit...@cr...> wrote: > is there any way in memcheck to detect out of bound array access, when using > stl objects like std::string and std::map ? No, but many such bugs can easily be detected by building with -D_GLIBCXX_DEBUG (when using recent g++ versions). See http://gcc.gnu.org/onlinedocs/libstdc++/debug_mode.html Also, there is no such thing as "out of bound array access" when using std::map, is there? Cheers, |