Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong mimalloc stat with asan #938

Open
thweetkomputer opened this issue Sep 11, 2024 · 1 comment
Open

Wrong mimalloc stat with asan #938

thweetkomputer opened this issue Sep 11, 2024 · 1 comment

Comments

@thweetkomputer
Copy link

#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?
image

But the stat shows normally when asan is disabled.
image

Can you help me?

@imsharukh1994
Copy link

imsharukh1994 commented Dec 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants