1

I've just ran into a drmemory error with my application with the following output:

Error #1: INVALID HEAP ARGUMENT to free
# 0 replace_operator_delete                            [d:\drmemory_package\common\alloc_replace.c:2496]
# 1 std::vector<>::~vector()                           [C:/Qt/Tools/mingw482_32/i686-w64-mingw32/include/c++/ext/new_allocator.h:110]
# 2 msvcrt.dll!exit      
# 3 _fu0___set_invalid_parameter_handler               [C:/Qt/Tools/mingw482_32/i686-w64-mingw32/include/c++/bits/stl_tree.h:1809]
# 4 KERNEL32.dll!BaseThreadInitThunk                  +0x11     (0x7651338a <KERNEL32.dll+0x1338a>)

I've absolutely no idea where to start looking for my bug. Does anybody have some idea? (The application I've run is quite complex, so I can't post thousands of lines here.)

Cactusjoe
  • 73
  • 5
  • At best you're going to get sheer speculation on this question, but my *guess* is somewhere in static linkage (a global, a static, etc) you have a `std::vector<>` that was corrupted with an overwrite of something nearby. Again, obviously a guess, but it would seem plausible. The crt's exit handler fires destructors for all globals, and this one detected a bogus heap pointer, which vectors should *never* have unless they've been compromised. – WhozCraig Sep 15 '14 at 07:25
  • Since you're using MSVC I'd recommend a combination of Visual Leak Detector (free) and any of the strategies recommended [in this answer](http://stackoverflow.com/questions/1010106/how-to-debug-heap-corruption-errors). – Andy Brown Sep 15 '14 at 07:46
  • I'm using mingw 4.8.2, not MSVC, so the Application Verifyer is not an option for me in this case. – Cactusjoe Sep 15 '14 at 08:24

0 Answers0