-
Notifications
You must be signed in to change notification settings - Fork 14k
Revert "lsan: Support free_sized and free_aligned_sized from C23" #144575
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
Revert "lsan: Support free_sized and free_aligned_sized from C23" #144575
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Justin King (jcking) ChangesReverts llvm/llvm-project#144415 Need to update approach to handle Apple platforms gracefully. Full diff: https://github.com/llvm/llvm-project/pull/144575.diff 5 Files Affected:
diff --git a/compiler-rt/lib/lsan/lsan_allocator.cpp b/compiler-rt/lib/lsan/lsan_allocator.cpp
index a436d9c07ac6c..493bf5f9efc57 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.cpp
+++ b/compiler-rt/lib/lsan/lsan_allocator.cpp
@@ -220,10 +220,6 @@ void lsan_free(void *p) {
Deallocate(p);
}
-void lsan_free_sized(void *p, uptr) { Deallocate(p); }
-
-void lsan_free_aligned_sized(void *p, uptr, uptr) { Deallocate(p); }
-
void *lsan_realloc(void *p, uptr size, const StackTrace &stack) {
return SetErrnoOnNull(Reallocate(stack, p, size, 1));
}
diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h
index 2342f11fb5d0d..5eed0cbdb309b 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.h
+++ b/compiler-rt/lib/lsan/lsan_allocator.h
@@ -127,8 +127,6 @@ void *lsan_aligned_alloc(uptr alignment, uptr size, const StackTrace &stack);
void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack);
void *lsan_malloc(uptr size, const StackTrace &stack);
void lsan_free(void *p);
-void lsan_free_sized(void *p, uptr size);
-void lsan_free_aligned_sized(void *p, uptr alignment, uptr size);
void *lsan_realloc(void *p, uptr size, const StackTrace &stack);
void *lsan_reallocarray(void *p, uptr nmemb, uptr size,
const StackTrace &stack);
diff --git a/compiler-rt/lib/lsan/lsan_interceptors.cpp b/compiler-rt/lib/lsan/lsan_interceptors.cpp
index 8e33130840e92..a8252cddacf25 100644
--- a/compiler-rt/lib/lsan/lsan_interceptors.cpp
+++ b/compiler-rt/lib/lsan/lsan_interceptors.cpp
@@ -84,24 +84,6 @@ INTERCEPTOR(void, free, void *p) {
lsan_free(p);
}
-INTERCEPTOR(void, free_sized, void *p, uptr size) {
- if (UNLIKELY(!p))
- return;
- if (DlsymAlloc::PointerIsMine(p))
- return DlsymAlloc::Free(p);
- ENSURE_LSAN_INITED;
- lsan_free_sized(p, size);
-}
-
-INTERCEPTOR(void, free_aligned_sized, void *p, uptr alignment, uptr size) {
- if (UNLIKELY(!p))
- return;
- if (DlsymAlloc::PointerIsMine(p))
- return DlsymAlloc::Free(p);
- ENSURE_LSAN_INITED;
- lsan_free_aligned_sized(p, alignment, size);
-}
-
INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
if (DlsymAlloc::Use())
return DlsymAlloc::Callocate(nmemb, size);
diff --git a/compiler-rt/lib/lsan/lsan_malloc_mac.cpp b/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
index 8a16c053da238..525c30272ccca 100644
--- a/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
+++ b/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
@@ -44,19 +44,16 @@ using namespace __lsan;
void *p = lsan_valloc(size, stack)
#define COMMON_MALLOC_FREE(ptr) \
lsan_free(ptr)
-# define COMMON_MALLOC_FREE_SIZED(ptr, size) lsan_free_sized(ptr, size)
-# define COMMON_MALLOC_FREE_ALIGNED_SIZED(ptr, alignment, size) \
- lsan_free_aligned_sized(ptr, alignment, size)
-# define COMMON_MALLOC_SIZE(ptr) uptr size = lsan_mz_size(ptr)
-# define COMMON_MALLOC_FILL_STATS(zone, stats)
-# define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
- (void)zone_name; \
- Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", \
- ptr);
-# define COMMON_MALLOC_NAMESPACE __lsan
-# define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
-# define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
+#define COMMON_MALLOC_SIZE(ptr) \
+ uptr size = lsan_mz_size(ptr)
+#define COMMON_MALLOC_FILL_STATS(zone, stats)
+#define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
+ (void)zone_name; \
+ Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);
+#define COMMON_MALLOC_NAMESPACE __lsan
+#define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
+#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
-# include "sanitizer_common/sanitizer_malloc_mac.inc"
+#include "sanitizer_common/sanitizer_malloc_mac.inc"
#endif // SANITIZER_APPLE
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
index 72ad22999b5a4..6343eb284afbf 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc
@@ -144,21 +144,6 @@ INTERCEPTOR(void, free, void *ptr) {
COMMON_MALLOC_FREE(ptr);
}
-#ifdef COMMON_MALLOC_FREE_SIZED
-INTERCEPTOR(void, free_sized, void *ptr, size_t size) {
- COMMON_MALLOC_ENTER();
- COMMON_MALLOC_FREE_SIZED(ptr, size);
-}
-#endif
-
-#ifdef COMMON_MALLOC_FREE_ALIGNED_SIZED
-INTERCEPTOR(void, free_aligned_sized, void *ptr, size_t alignment,
- size_t size) {
- COMMON_MALLOC_ENTER();
- COMMON_MALLOC_FREE_ALIGNED_SIZED(ptr, alignment, size);
-}
-#endif
-
INTERCEPTOR(void *, realloc, void *ptr, size_t size) {
COMMON_MALLOC_ENTER();
COMMON_MALLOC_REALLOC(ptr, size);
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions cpp,h,inc -- compiler-rt/lib/lsan/lsan_allocator.cpp compiler-rt/lib/lsan/lsan_allocator.h compiler-rt/lib/lsan/lsan_interceptors.cpp compiler-rt/lib/lsan/lsan_malloc_mac.cpp compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc View the diff from clang-format here.diff --git a/compiler-rt/lib/lsan/lsan_malloc_mac.cpp b/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
index 525c30272..1dd95d501 100644
--- a/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
+++ b/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
@@ -44,16 +44,16 @@ using namespace __lsan;
void *p = lsan_valloc(size, stack)
#define COMMON_MALLOC_FREE(ptr) \
lsan_free(ptr)
-#define COMMON_MALLOC_SIZE(ptr) \
- uptr size = lsan_mz_size(ptr)
-#define COMMON_MALLOC_FILL_STATS(zone, stats)
-#define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
- (void)zone_name; \
- Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);
-#define COMMON_MALLOC_NAMESPACE __lsan
-#define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
-#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
+# define COMMON_MALLOC_SIZE(ptr) uptr size = lsan_mz_size(ptr)
+# define COMMON_MALLOC_FILL_STATS(zone, stats)
+# define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
+ (void)zone_name; \
+ Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", \
+ ptr);
+# define COMMON_MALLOC_NAMESPACE __lsan
+# define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
+# define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
-#include "sanitizer_common/sanitizer_malloc_mac.inc"
+# include "sanitizer_common/sanitizer_malloc_mac.inc"
#endif // SANITIZER_APPLE
|
Thanks for reverting. Please feel free add me if you want any Apple eyes on sanitizer-related PRs in the future! |
Reverts #144415
Need to update approach to handle Apple platforms gracefully.