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

[ASAN] mallinfo() function do not work with address sanitizer #1845

Open
sendaoYan opened this issue Feb 6, 2025 · 0 comments
Open

[ASAN] mallinfo() function do not work with address sanitizer #1845

sendaoYan opened this issue Feb 6, 2025 · 0 comments

Comments

@sendaoYan
Copy link

sendaoYan commented Feb 6, 2025

Without -fsanitize=address, mallinfo() works normally.

gcc mallinfo.c && ./a.out
0, 1, 0, 0, 0, 0, 0, 0, 0, 0
135168, 1, 0, 0, 0, 0, 0, 67248, 67920, 67920

With -fsanitize=address, mallinfo() works abnormally.

gcc -fsanitize=address mallinfo.c && ./a.out
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0

mallinfo.c:

#include <stdio.h>
#include <malloc.h>

int main() {
    struct mallinfo info;
    info = mallinfo();

    printf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", info.arena, info.ordblks, info.smblks, info.hblks, info.hblkhd, info.usmblks, info.fsmblks, info.uordblks, info.fordblks, info.keepcost);

    char* ptr = malloc(0x10000);
    info = mallinfo();

    printf("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", info.arena, info.ordblks, info.smblks, info.hblks, info.hblkhd, info.usmblks, info.fsmblks, info.uordblks, info.fordblks, info.keepcost);

    free(ptr);
    return 0;
}
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

1 participant