DynamoRIO / drmemory

Memory Debugger for Windows, Linux, Mac, and Android
Other
2.44k stars 262 forks source link

CRASH calling chromium malloc_usable_size() when jemalloc not selected #314

Open derekbruening opened 9 years ago

derekbruening commented 9 years ago

From bruen...@google.com on March 02, 2011 13:51:53

running chromium's unit_tests.exe, if anything but jemalloc is selected, malloc_usable_size() will crash (b/c it's part of jemalloc). the problem is that heap routine selection is done inside of malloc(), so to Dr. Memory there is a malloc() and malloc_usable_size() pair, yet as it turns out they do not go together since malloc() calls into tcmalloc, and the size routine to pair with it in that case is tc_malloc_usable_size(). yet malloc_usable_size() does not perform dynamic heap selection and is hardocded for jemalloc.

xref issue #267

Original issue: http://code.google.com/p/drmemory/issues/detail?id=314

derekbruening commented 9 years ago

From bruen...@google.com on March 03, 2011 13:38:41

with CHROME_ALLOCATOR=jemalloc we hit issue #320 one option: unset CHROME_ALLOCATOR and add a tc_malloc_usable_size line so it takes precedence. and now unit_tests works on DownloadManagerTest.* that's a hack though (breaks linux).

could instead use winheap allocator and ignore malloc, realloc, free, and _msize. same approach could work w/ tcmalloc if consider "do_malloc" a tcmalloc routine, and do_realloc, and add tc_malloc_usable_size to go with it.

or, use winheap allocator and have option -ignore_usable_size or -prefer_msize? may as well have -prefer_msize on by default since rare on windows to see both _msize and malloc_usable_size