[compiler-rt] enable_unmalloced_free_check (PR #139125)
Jake Egan via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 11:49:25 PDT 2025
https://github.com/jakeegan updated https://github.com/llvm/llvm-project/pull/139125
>From d3ef61e69322f48d1b66b04183cc32d7896cbfed Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Thu, 8 May 2025 14:40:52 -0400
Subject: [PATCH 1/2] enable_unmalloced_free_check
---
compiler-rt/lib/asan/asan_allocator.cpp | 6 ++++--
compiler-rt/lib/sanitizer_common/sanitizer_flags.inc | 3 +++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index 3a55c2af65653..3208d9feb6212 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -797,8 +797,10 @@ struct Allocator {
void ReportInvalidFree(void *ptr, u8 chunk_state, BufferedStackTrace *stack) {
if (chunk_state == CHUNK_QUARANTINE)
ReportDoubleFree((uptr)ptr, stack);
- else
- ReportFreeNotMalloced((uptr)ptr, stack);
+ else {
+ if (common_flags()->enable_unmalloced_free_check)
+ ReportFreeNotMalloced((uptr)ptr, stack);
+ }
}
void CommitBack(AsanThreadLocalMallocStorage *ms, BufferedStackTrace *stack) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
index c1e3530618c20..4b4460d93388d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -282,3 +282,6 @@ COMMON_FLAG(bool, enable_symbolizer_markup, SANITIZER_FUCHSIA,
COMMON_FLAG(bool, detect_invalid_join, true,
"If set, check invalid joins of threads.")
+COMMON_FLAG(bool, enable_unmalloced_free_check, !SANITIZER_AIX,
+ "if true, FreeNotMalloced error will be reported. Only disable "
+ "this error detecting on AIX by default for now.")
>From b158df17726d470f6d6b3825a6686f29f648eb69 Mon Sep 17 00:00:00 2001
From: Jake Egan <jake.egan at ibm.com>
Date: Thu, 8 May 2025 14:49:12 -0400
Subject: [PATCH 2/2] Fix formatting
---
compiler-rt/lib/asan/asan_allocator.cpp | 6 +++---
compiler-rt/lib/sanitizer_common/sanitizer_flags.inc | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/asan/asan_allocator.cpp b/compiler-rt/lib/asan/asan_allocator.cpp
index 3208d9feb6212..8a56132bf946a 100644
--- a/compiler-rt/lib/asan/asan_allocator.cpp
+++ b/compiler-rt/lib/asan/asan_allocator.cpp
@@ -798,9 +798,9 @@ struct Allocator {
if (chunk_state == CHUNK_QUARANTINE)
ReportDoubleFree((uptr)ptr, stack);
else {
- if (common_flags()->enable_unmalloced_free_check)
- ReportFreeNotMalloced((uptr)ptr, stack);
- }
+ if (common_flags()->enable_unmalloced_free_check)
+ ReportFreeNotMalloced((uptr)ptr, stack);
+ }
}
void CommitBack(AsanThreadLocalMallocStorage *ms, BufferedStackTrace *stack) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
index 4b4460d93388d..e7d0f3a6d6496 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
@@ -283,5 +283,5 @@ COMMON_FLAG(bool, enable_symbolizer_markup, SANITIZER_FUCHSIA,
COMMON_FLAG(bool, detect_invalid_join, true,
"If set, check invalid joins of threads.")
COMMON_FLAG(bool, enable_unmalloced_free_check, !SANITIZER_AIX,
- "if true, FreeNotMalloced error will be reported. Only disable "
- "this error detecting on AIX by default for now.")
+ "if true, FreeNotMalloced error will be reported. Only disable "
+ "this error detecting on AIX by default for now.")
More information about the llvm-commits
mailing list