-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 is almost unusable on AArch64. #703
Comments
We could add a bitmap which says what regions are non-empty. |
Before trying to fix this problem, please remind me: do we really need to support VMA 39 and 42? |
Well, I hit on this problem trying to run LSan on my 39-bit target mobile device. I'm not sure our customers would switch to 48 bits soon and it would be nice for us to use LSan now. AFAIK Fedora uses 42 bit VMA, but I'm not sure they tried to use LSan there. |
Sad. The current code effectively makes 48-bit case slow because we have to support the smaller cases. I think the next possible solution is to build an iterator inside ByteMap. |
Yeah, this sounds complicated, Aarch64 is so problematic... Can't we calculate kNumPossibleRegions somehow on demand in SizeClassAllocator32 (say, before allocating first region)? |
sure we can, but what I'd really love to do is to simply switch to SizeClassAllocator64 for 48-bit vma, |
Perhaps we could pick primary allocator dynamically? Say, in InitializeAllocator routine. This would imply some space overhead though. |
This will have both space and time overhead. |
@kcc: What's the status of this now? |
Looks like the problem is still there:
I am tempted to disable lsan on aarch64 before someone can fix it. |
@ebahapo and I will be looking at this bug. |
@kcc do you happen to know a better way to get the size of the VMA other than |
Not an expert here. I would either read |
Main thread stack is almost always mapped in the upper half of the address
space. Finding the most significant bit of the frame address should work in
practice. See GetMaxVirtualAddress in sanitizer_linux.cc.
…On Fri, Feb 22, 2019 at 2:00 PM Kostya Serebryany ***@***.***> wrote:
Not an expert here. I would either read /proc/meminfo or /proc/self/maps.
I guess you can also probe with mmap
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#703 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAZuSheo7X3ONfL-l3n6FJx_MOW-pfW8ks5vQGhqgaJpZM4JavEG>
.
|
Yes GetMaxVirtualAddress would work. Thanks @eugenis for the suggestion. |
I tried to implement this:
Runtime switching 32 and 64-bit allocators would require too many changes to the current implementation of the allocators. Then I followed this path:
The following patch disables LSan on aarch64 for 39 and 42-bit VMAs, and enables the 64-bit allocator by default on aarch64 machines with 47-bit VMA:
On a 47-bit VMA aarch64 machine the time spent in LSan reduced from
The patch passes |
This patch will fix the standalone lsan ( |
You are right, I have just tried with asan and it takes |
Emm.. What will happen on 47-bit? It will still have the Allocator32, right? |
I just sent a patch for review https://reviews.llvm.org/D60243 |
This patch fixes google/sanitizers#703 On a Graviton-A1 aarch64 machine with 48-bit VMA, the time spent in LSan and ASan reduced from 2.5s to 0.01s when running clang -fsanitize=leak compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out clang -fsanitize=address compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out With this patch, LSan and ASan create both the 32 and 64 allocators and select at run time between the two allocators following a global variable that is initialized at init time to whether the allocator64 can be used in the virtual address space. Differential Revision: https://reviews.llvm.org/D60243 llvm-svn: 369441
This patch fixes google/sanitizers#703 On a Graviton-A1 aarch64 machine with 48-bit VMA, the time spent in LSan and ASan reduced from 2.5s to 0.01s when running clang -fsanitize=leak compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out clang -fsanitize=address compiler-rt/test/lsan/TestCases/sanity_check_pure_c.c && time ./a.out With this patch, LSan and ASan create both the 32 and 64 allocators and select at run time between the two allocators following a global variable that is initialized at init time to whether the allocator64 can be used in the virtual address space. Differential Revision: https://reviews.llvm.org/D60243 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@369441 91177308-0d34-0410-b5e6-96231b3b80d8
…locator. This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ google/sanitizers#703 | issues/703 ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator. Reviewed By: vitalybuka, MaskRay Differential Revision: https://reviews.llvm.org/D137136
…locator. This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ google/sanitizers#703 | issues/703 ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator. Reviewed By: vitalybuka, MaskRay Differential Revision: https://reviews.llvm.org/D137136
…locator. This change will switch SizeClassAllocator32 to SizeClassAllocator64 on ARM. This might potentially affect ARM platforms with 39-bit address space. This addresses [[ google/sanitizers#703 | issues/703 ]], but unlike [[ https://reviews.llvm.org/D60243 | D60243 ]] it defaults to 64 bit allocator. Reviewed By: vitalybuka, MaskRay Differential Revision: https://reviews.llvm.org/D137136
LSan works very slow even on trivial hello-world leaks. This happens because Aarch64 uses SizeClassAllocator32, in particular, here the code of ForEachChunk method of SizeClassAllocator32, that LSan calls several times:
For 39-bit VMA kNumPossibleRegions is calculated as:
that equals to
2^47 / 2^20 == 2^27
, thus we have a very busy loop in SizeClassAllocator32.The problem I faced when trying to fix this is that actual VMA size (39, 42 or 48) is calculated dynamically at runtime, while allocator needs kSpaceSize to be determined statically. I wonder whether we could fix this in some way? Ideally, it would be nice to use SizeClassAllocator64, but it seems to be impossible according to #246. Any ideas?
The text was updated successfully, but these errors were encountered: