[compiler-rt] rtsan: Support free_sized and free_aligned_sized from C23 (PR #145085)
Justin King via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 13:08:16 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))
----------------
jcking wrote:
Probably not. In this case, an acceptable implementation of `free_sized` and `free_aligned_sized` is just calling `free`. Since we have that option easily implementable here, we forward. The likelihood that somebody manages to call this function without a real underlying function is low, but it still seemed better to not crash if somebody managed to `dlsym`.
https://github.com/llvm/llvm-project/pull/145085
More information about the llvm-commits
mailing list