diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 41c0c8b51fdfbbccd7664ec55cf4f006fc1beff5..fe7df6f4fa533f4a972e74fc3432f7504bca58de 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 15f399a0a7f01ba6d436e84a94f25c2c0634cdd8..4726b7e95e28ae132f3ffb659dfbdded4e726ca4 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, "")