Skip to content

Commit 2e10af6

Browse files
tmiaskotru
authored andcommitted
[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 ae0ed3d)
1 parent 8ef2858 commit 2e10af6

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

compiler-rt/lib/lsan/lsan_interceptors.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ INTERCEPTOR(void*, malloc, uptr size) {
7777
}
7878

7979
INTERCEPTOR(void, free, void *p) {
80+
if (UNLIKELY(!p))
81+
return;
8082
if (DlsymAlloc::PointerIsMine(p))
8183
return DlsymAlloc::Free(p);
8284
ENSURE_LSAN_INITED;

compiler-rt/test/sanitizer_common/TestCases/dlsym_alloc.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// FIXME: TSAN does not use DlsymAlloc.
44
// UNSUPPORTED: tsan
55

6-
// FIXME: https://github.com/llvm/llvm-project/pull/106912
7-
// XFAIL: lsan
8-
96
#include <stdlib.h>
107

118
const char *test() __attribute__((disable_sanitizer_instrumentation)) {

0 commit comments

Comments
 (0)