mimalloc
mimalloc copied to clipboard
Wrong mimalloc stat with asan
#include <stdlib.h>
int main() {
int *a = (int *)malloc(sizeof(int));
*a = 1;
return 0;
}
Hi, I wrote a demo and want to use mimalloc with asan enabled.
gcc test.c -I/usr/local/include/mimalloc-2.1 -lmimalloc-asan-debug -fsanitize=address -fsanitize-recover=address -lpthre
I found that the stats all become zero, is this normal?
But the stat shows normally when asan is disabled.
Can you help me?
If you just need ASan’s checks and mimalloc for the allocation, try using ASan with mimalloc without enabling mimalloc’s stats:
gcc test.c -I/usr/local/include/mimalloc-2.1 -lmimalloc-asan-debug -fsanitize=address -fsanitize-recover=address -lpthread
If you need mimalloc stats, disable ASan for the time being or use mimalloc’s default allocator without ASan’s intervention. You could compile with:
gcc test.c -I/usr/local/include/mimalloc-2.1 -lmimalloc -lm -lpthread
This should ensure that mimalloc tracks memory correctly and reports statistics.