[compiler-rt] rtsan: Support free_sized and free_aligned_sized from C23 (PR #145085)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 09:29:19 PDT 2025
================
@@ -869,6 +869,48 @@ INTERCEPTOR(void, free, void *ptr) {
return REAL(free)(ptr);
}
+#if SANITIZER_INTERCEPT_FREE_SIZED
+INTERCEPTOR(void, free_sized, void *ptr, SIZE_T size) {
+ if (DlsymAlloc::PointerIsMine(ptr))
+ return DlsymAlloc::Free(ptr);
+
+ // According to the C and C++ standard, freeing a nullptr is guaranteed to be
+ // a no-op (and thus real-time safe). This can be confirmed for looking at
+ // __libc_free in the glibc source.
+ if (ptr != nullptr)
+ __rtsan_notify_intercepted_call("free_sized");
+
+ if (REAL(free_sized))
----------------
cjappl wrote:
Is this something we should do with the rest of our interceptors as well?
It was my previous understanding that if someone got into this interceptor without a valid REAL version on their system, their binary would likely crash and die (which is acceptable, because they called some illegal function).
https://github.com/llvm/llvm-project/pull/145085
More information about the llvm-commits
mailing list