Note that there are some explanatory texts on larger screens.

plurals
  1. POHeap corruption not detected by Valgrind or Electric Fence. Should I be suspicious? (C++)
    primarykey
    data
    text
    <p>I recently encountered my first <a href="https://stackoverflow.com/questions/5767900/struggling-yet-another-memory-corruption-problem-bad-alloc-c-vs-2008">battle</a> <strong>(solved)</strong> with heap corruption. On my linux machine at home the culprit code exits without error using valgrind and electric-fence(with gdb). Yet on the windows machine in our lab, I consistently get the heap corruption related error message from VS described in my referenced post.</p> <p>Is it surprising (or at least uncommon) that valgrind and electric fence wouldn't detect such a problem? Someone else mentioned a possibly similar bug that eluded valgrind in a answer <a href="https://stackoverflow.com/questions/7525/of-memory-management-heap-corruption-and-c">here</a>. What might be some reasons why this problem wouldn't be detected by these tools? Is there any reason to doubt that error is in fact heap corruption?</p> <p><strong>Update</strong>: As mentioned in the post describing the original problem, I found that the problem was due to having pointers to elements in a std::vector, which became bad. Replacing the vectors with std::list (to which pointers don't become invalid when adding new elements) fixed the problem. So getting back to my question about why valgrind didn't detect the problem, I ask if there are any recommendations about how to avoid a similar situation in the future, namely a memory problem that isn't detected by valgrind which is one of my favorite tools. Obviously getting a better understanding of how STL works would be a good idea. Perhaps I need to be more assertive with assert in my programming, etc. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload