From 4904be0f2725c0e158a3267876a3030f9aded3dc Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 27 Feb 2025 17:10:13 +0800 Subject: [PATCH] l[Compier-RT][HWASAN] Fix cppcrash issue on TW Controlled by the `run_on_tw` option, it does not affect the normal application functions. Signed-off-by: Eric --- compiler-rt/lib/sanitizer_common/sanitizer_flags.inc | 5 +++++ .../lib/sanitizer_common/sanitizer_symbolizer_report.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc index 15a253feb116..52c08d8e3ce2 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc @@ -275,3 +275,8 @@ COMMON_FLAG(bool, detect_write_exec, false, COMMON_FLAG(bool, test_only_emulate_no_memorymap, false, "TEST ONLY fail to read memory mappings to emulate sanitized " "\"init\"") + +// OHOS_LOCAL begin +COMMON_FLAG(bool, run_on_tw, false, + "If true, no abort.") +// OHOS_LOCAL end \ No newline at end of file diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp index 31eebd293f29..9db928f92ab0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp @@ -250,6 +250,12 @@ void HandleDeadlySignal(void *siginfo, void *context, u32 tid, ScopedErrorReportLock rl; SignalContext sig(siginfo, context); ReportDeadlySignal(sig, tid, unwind, unwind_context); +// OHOS_LOCAL begin + if (!common_flags()->run_on_tw) { + Report("ABORTING\n"); + Die(); + } +// OHOS_LOCAL end } #endif // !SANITIZER_FUCHSIA && !SANITIZER_GO -- Gitee