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

LSan doesn't detect leaks with mmap #1224

Closed
ghost opened this issue Apr 14, 2020 · 2 comments
Closed

LSan doesn't detect leaks with mmap #1224

ghost opened this issue Apr 14, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 14, 2020

Hello, thank you for this project
While I'm using LSan I found that it doesn't detect leaks with mmap

Is there any reason why ?
It must be great if someone let me know !

test code is simple like below

#include <sys/mman.h>

int main() {
    int* ptr2 = (int*)mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
}
@ghost ghost changed the title LSan doesn't detect leaks with mmap syscall LSan doesn't detect leaks with mmap Apr 14, 2020
@kcc
Copy link
Contributor

kcc commented Apr 14, 2020

lsan is a heap (malloc) leak detector.

It's hard to even define what is an mmap leak, because mmap-ed data doesn't really ever leak - you can still find all the mappings in /proc/maps and unmap what you don't need, even if all pointers to that mapping are lost.

It should be possible to extend lsan to do the following:

  • scan all memory to find all pointers to all currently mmap-ed regions (lsan does the full scan anyway).
  • report mappings that no pointers are pointing to

I don't know how useful such tool is going to be.
(And we are not planing this work)

@ghost
Copy link
Author

ghost commented Apr 15, 2020

Thank you for the comment
I learned much^^

This issue was closed.
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