Skip to content

Commit 80f3a28

Browse files
authored
Revert "lsan: Support free_sized and free_aligned_sized from C23" (#144575)
Reverts #144415 Need to update approach to handle Apple platforms gracefully.
1 parent 8cd05b8 commit 80f3a28

File tree

5 files changed

+10
-52
lines changed

5 files changed

+10
-52
lines changed

compiler-rt/lib/lsan/lsan_allocator.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,6 @@ void lsan_free(void *p) {
220220
Deallocate(p);
221221
}
222222

223-
void lsan_free_sized(void *p, uptr) { Deallocate(p); }
224-
225-
void lsan_free_aligned_sized(void *p, uptr, uptr) { Deallocate(p); }
226-
227223
void *lsan_realloc(void *p, uptr size, const StackTrace &stack) {
228224
return SetErrnoOnNull(Reallocate(stack, p, size, 1));
229225
}

compiler-rt/lib/lsan/lsan_allocator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ void *lsan_aligned_alloc(uptr alignment, uptr size, const StackTrace &stack);
127127
void *lsan_memalign(uptr alignment, uptr size, const StackTrace &stack);
128128
void *lsan_malloc(uptr size, const StackTrace &stack);
129129
void lsan_free(void *p);
130-
void lsan_free_sized(void *p, uptr size);
131-
void lsan_free_aligned_sized(void *p, uptr alignment, uptr size);
132130
void *lsan_realloc(void *p, uptr size, const StackTrace &stack);
133131
void *lsan_reallocarray(void *p, uptr nmemb, uptr size,
134132
const StackTrace &stack);

compiler-rt/lib/lsan/lsan_interceptors.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,6 @@ INTERCEPTOR(void, free, void *p) {
8484
lsan_free(p);
8585
}
8686

87-
INTERCEPTOR(void, free_sized, void *p, uptr size) {
88-
if (UNLIKELY(!p))
89-
return;
90-
if (DlsymAlloc::PointerIsMine(p))
91-
return DlsymAlloc::Free(p);
92-
ENSURE_LSAN_INITED;
93-
lsan_free_sized(p, size);
94-
}
95-
96-
INTERCEPTOR(void, free_aligned_sized, void *p, uptr alignment, uptr size) {
97-
if (UNLIKELY(!p))
98-
return;
99-
if (DlsymAlloc::PointerIsMine(p))
100-
return DlsymAlloc::Free(p);
101-
ENSURE_LSAN_INITED;
102-
lsan_free_aligned_sized(p, alignment, size);
103-
}
104-
10587
INTERCEPTOR(void*, calloc, uptr nmemb, uptr size) {
10688
if (DlsymAlloc::Use())
10789
return DlsymAlloc::Callocate(nmemb, size);

compiler-rt/lib/lsan/lsan_malloc_mac.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,16 @@ using namespace __lsan;
4444
void *p = lsan_valloc(size, stack)
4545
#define COMMON_MALLOC_FREE(ptr) \
4646
lsan_free(ptr)
47-
# define COMMON_MALLOC_FREE_SIZED(ptr, size) lsan_free_sized(ptr, size)
48-
# define COMMON_MALLOC_FREE_ALIGNED_SIZED(ptr, alignment, size) \
49-
lsan_free_aligned_sized(ptr, alignment, size)
50-
# define COMMON_MALLOC_SIZE(ptr) uptr size = lsan_mz_size(ptr)
51-
# define COMMON_MALLOC_FILL_STATS(zone, stats)
52-
# define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
53-
(void)zone_name; \
54-
Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", \
55-
ptr);
56-
# define COMMON_MALLOC_NAMESPACE __lsan
57-
# define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
58-
# define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
47+
#define COMMON_MALLOC_SIZE(ptr) \
48+
uptr size = lsan_mz_size(ptr)
49+
#define COMMON_MALLOC_FILL_STATS(zone, stats)
50+
#define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
51+
(void)zone_name; \
52+
Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);
53+
#define COMMON_MALLOC_NAMESPACE __lsan
54+
#define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0
55+
#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0
5956

60-
# include "sanitizer_common/sanitizer_malloc_mac.inc"
57+
#include "sanitizer_common/sanitizer_malloc_mac.inc"
6158

6259
#endif // SANITIZER_APPLE

compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,6 @@ INTERCEPTOR(void, free, void *ptr) {
144144
COMMON_MALLOC_FREE(ptr);
145145
}
146146

147-
#ifdef COMMON_MALLOC_FREE_SIZED
148-
INTERCEPTOR(void, free_sized, void *ptr, size_t size) {
149-
COMMON_MALLOC_ENTER();
150-
COMMON_MALLOC_FREE_SIZED(ptr, size);
151-
}
152-
#endif
153-
154-
#ifdef COMMON_MALLOC_FREE_ALIGNED_SIZED
155-
INTERCEPTOR(void, free_aligned_sized, void *ptr, size_t alignment,
156-
size_t size) {
157-
COMMON_MALLOC_ENTER();
158-
COMMON_MALLOC_FREE_ALIGNED_SIZED(ptr, alignment, size);
159-
}
160-
#endif
161-
162147
INTERCEPTOR(void *, realloc, void *ptr, size_t size) {
163148
COMMON_MALLOC_ENTER();
164149
COMMON_MALLOC_REALLOC(ptr, size);

0 commit comments

Comments
 (0)