[llvm-branch-commits] [compiler-rt] 2e10af6 - [lsan] Fix free(NULL) interception during initialization (#106912)
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 13 02:53:18 PST 2025
Author: tmiasko
Date: 2025-01-13T11:53:16+01:00
New Revision: 2e10af6e59258da02167fc66e5e6ecd0549da62a
URL: https://github.com/llvm/llvm-project/commit/2e10af6e59258da02167fc66e5e6ecd0549da62a
DIFF: https://github.com/llvm/llvm-project/commit/2e10af6e59258da02167fc66e5e6ecd0549da62a.diff
LOG: [lsan] Fix free(NULL) interception during initialization (#106912)
Previously an attempt to free a null pointer during initialization would
fail on ENSURE_LSAN_INITED assertion (since a null pointer is not owned
by DlsymAlloc).
(cherry picked from commit ae0ed3d58600da9ec266bf86d0084775f561ba3a)
Added:
Modified:
compiler-rt/lib/lsan/lsan_interceptors.cpp
compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index b569c337e97641..efbf2fdfb0ab3f 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -77,6 +77,8 @@ INTERCEPTOR(void*, malloc, uptr size) {
}
INTERCEPTOR(void, free, void *p) {
+ if (UNLIKELY(!p))
+ return;
if (DlsymAlloc::PointerIsMine(p))
return DlsymAlloc::Free(p);
ENSURE_LSAN_INITED;
diff --git a/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
index 3905ac40ae2dc7..0228c3bc50dbd9 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
+++ b/compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c
@@ -3,9 +3,6 @@
// FIXME: TSAN does not use DlsymAlloc.
// UNSUPPORTED: tsan
-// FIXME: https://github.com/llvm/llvm-project/pull/106912
-// XFAIL: lsan
-
#include <stdlib.h>
const char *test() __attribute__((disable_sanitizer_instrumentation)) {
More information about the llvm-branch-commits
mailing list