[compiler-rt] [LSan] Use exit caller SP for explicit exit leak checks (PR #195238)
Kunqiu Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri May 1 02:09:26 PDT 2026
================
@@ -563,6 +563,16 @@ INTERCEPTOR(void, _exit, int status) {
REAL(_exit)(status);
}
+// TODO: Intercept more program-killing functions that behave like exit().
+INTERCEPTOR(void, exit, int status) {
+ if (lsan_inited && common_flags()->detect_leaks &&
+ common_flags()->leak_check_at_exit) {
+ // Capture the boundary before libc runs atexit handlers.
+ RecordExitCallerSP(GET_CURRENT_FRAME());
+ }
+ REAL(exit)(status);
+}
+
#define COMMON_INTERCEPT_FUNCTION(name) INTERCEPT_FUNCTION(name)
#define SIGNAL_INTERCEPTOR_ENTER() ENSURE_LSAN_INITED
#include "sanitizer_common/sanitizer_signal_interceptors.inc"
----------------
Camsyn wrote:
The code formatter complains about this format.
I found that `*san/.clang-format` declares that the sanitizer runtime code follows Google style format (`BasedOnStyle: Google`). However, there are countless places violating such a rule (e..g, Google style uses `char* p` rather than `char *p`).
https://github.com/llvm/llvm-project/pull/195238
More information about the llvm-commits
mailing list