-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Sanitizer CHECK failed: ((allocated_for_dlsym)) < ((kDlsymAllocPoolSize)) (0x402, 0x400)) with preload #51620
Comments
A simpler reproducer: [hjl@gnu-skx-1 gcc]$ LD_PRELOAD=/tmp/export-users-hjl-build-gnu-tools-build-gcc-debug-build-x86_64-linux-x86_64-pc-linux-gnu/libclang_rt.asan-i386.so ./a.out [hjl@gnu-skx-1 gcc]$ |
In glibc 2.34, dlsym does
so that has a memory leak. |
Reproducible by bots on Ubuntu 21.10 https://lab.llvm.org/staging/#/builders/19/builds/654/steps/8/logs/stdio |
Fixed with cb0e14c But if we want to cherry-pick we need 4 patches. 1da33a5 [NFC][sanitizer] Move GET_MALLOC_STACK_TRACE closer to the use |
And diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_dlsym.h
|
This is not a regression in LLVM, it's changes in glibc. I am not sure if it safe to cherry-pick all these patches into release today. Maybe after a couple of weeks? If someone can test, maybe this trivial change is safe and good enough? |
I tested this on release/13.x branch on Fedora 35 with glibc 2.34: diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index c6bec8551bc5..b4552428f425 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -30,7 +30,7 @@ using namespace __asan;
static uptr allocated_for_dlsym;
static uptr last_dlsym_alloc_size_in_words;
-static const uptr kDlsymAllocPoolSize = 1024;
+static const uptr kDlsymAllocPoolSize = 2048;
static uptr alloc_memory_for_dlsym[kDlsymAllocPoolSize];
static inline bool IsInDlsymAllocPool(const void *ptr) { It fixes the problem. |
Reopening for 13.x backport. The change from 1024 to 2048 fixes most of the test failures for me (on Gentoo amd64) but not all of them. I'm trying 4096 now. |
The smallest power of 2 that I've been able to get |
@vitalybuka Is it OK to bump the size this high on the release/13.x branch? |
Yes |
@mgorny Can you prepare a branch with this change and push it to a github fork? |
/branch mgorny/llvm-project/13-kdlsymalloc |
Merged: d96358a |
…le check Ref: llvm/llvm-project#51620 Note: currently, clang-13 supports 8192 bytes which is still not enough
Extended Description
With glibc 2.34 on Linux/x86-64, LLVM 13.0.0 rc1 gave me:
[hjl@gnu-skx-1 gcc]$ cat x.c
#include <assert.h>
struct A {
char a[3];
int b[3];
};
volatile int ten = 10;
attribute((noinline)) void foo(int index, int len) {
volatile struct A str[len] attribute((aligned(32)));
assert(!((long) str & 31L));
str[index].a[0] = '1'; // BOOM
}
int main(int argc, char **argv) {
foo(ten, ten);
return 0;
}
[hjl@gnu-skx-1 gcc]$ clang -O0 -fsanitize=address x.c -shared-libasan -m32
[hjl@gnu-skx-1 gcc]$ LD_PRELOAD=/export/users/hjl/build/gnu/tools-build/gcc-debug/build-x86_64-linux/x86_64-pc-linux-gnu/32/libsanitizer/libclang_rt.asan-i386.so ./a.out
AddressSanitizer: CHECK failed: asan_malloc_linux.cpp:46 "((allocated_for_dlsym)) < ((kDlsymAllocPoolSize))" (0x402, 0x400) (tid=3485465)
[hjl@gnu-skx-1 gcc]$
depending on the directory length where libclang_rt.asan-i386.so is placed.
The text was updated successfully, but these errors were encountered: