From ff591596ab6f1acf28fa6047f45333e1c7dca4c0 Mon Sep 17 00:00:00 2001 From: meteors117 Date: Tue, 11 Feb 2025 14:12:45 +0800 Subject: [PATCH] Add memory_debug flag. Signed-off-by: meteors117 --- compiler-rt/lib/hwasan/hwasan.cpp | 8 ++++++++ compiler-rt/lib/hwasan/hwasan_flags.inc | 2 ++ 2 files changed, 10 insertions(+) diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 41c0c8b51fdf..fe7df6f4fa53 100644 --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -369,6 +369,14 @@ __attribute__((constructor(0))) void __hwasan_init() { __ubsan::InitAsPlugin(); #endif +// OHOS_LOCAL begin + if (flags()->memory_debug) { + flags()->max_malloc_fill_size = 256; + flags()->max_free_fill_size = 256; + flags()->heap_quarantine_max = 1024 + 1; + } +// OHOS_LOCAL end + VPrintf(1, "HWAddressSanitizer init done\n"); hwasan_init_is_running = 0; diff --git a/compiler-rt/lib/hwasan/hwasan_flags.inc b/compiler-rt/lib/hwasan/hwasan_flags.inc index 15f399a0a7f0..4726b7e95e28 100644 --- a/compiler-rt/lib/hwasan/hwasan_flags.inc +++ b/compiler-rt/lib/hwasan/hwasan_flags.inc @@ -24,6 +24,8 @@ HWASAN_FLAG(bool, print_stats, false, "") HWASAN_FLAG(bool, halt_on_error, true, "") HWASAN_FLAG(bool, atexit, false, "") +HWASAN_FLAG(bool, memory_debug, false, "") // OHOS_LOCAL + // Test only flag to disable malloc/realloc/free memory tagging on startup. // Tagging can be reenabled with __hwasan_enable_allocator_tagging(). HWASAN_FLAG(bool, disable_allocator_tagging, false, "") -- Gitee