[compiler-rt] 1cf1727 - [HWASAN] Add leak sanitizer flag support
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 00:04:07 PST 2023
Author: Kirill Stoimenov
Date: 2023-01-18T00:03:51-08:00
New Revision: 1cf17279cc6eed4b5784378b538652c9ab2eeb4e
URL: https://github.com/llvm/llvm-project/commit/1cf17279cc6eed4b5784378b538652c9ab2eeb4e
DIFF: https://github.com/llvm/llvm-project/commit/1cf17279cc6eed4b5784378b538652c9ab2eeb4e.diff
LOG: [HWASAN] Add leak sanitizer flag support
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D141710
Added:
Modified:
compiler-rt/lib/hwasan/hwasan.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp
index 9db4fb09409c..70d123b0b1e6 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cpp
@@ -86,6 +86,8 @@ static void InitializeFlags() {
cf.clear_shadow_mmap_threshold = 4096 * (SANITIZER_ANDROID ? 2 : 8);
// Sigtrap is used in error reporting.
cf.handle_sigtrap = kHandleSignalExclusive;
+ // FIXME: enable once all false positives have been fixed.
+ cf.detect_leaks = false;
#if SANITIZER_ANDROID
// Let platform handle other signals. It is better at reporting them then we
@@ -106,6 +108,15 @@ static void InitializeFlags() {
RegisterHwasanFlags(&parser, f);
RegisterCommonFlags(&parser);
+#if CAN_SANITIZE_LEAKS
+ __lsan::Flags *lf = __lsan::flags();
+ lf->SetDefaults();
+
+ FlagParser lsan_parser;
+ __lsan::RegisterLsanFlags(&lsan_parser, lf);
+ RegisterCommonFlags(&lsan_parser);
+#endif
+
#if HWASAN_CONTAINS_UBSAN
__ubsan::Flags *uf = __ubsan::flags();
uf->SetDefaults();
@@ -124,6 +135,9 @@ static void InitializeFlags() {
#endif
parser.ParseStringFromEnv("HWASAN_OPTIONS");
+#if CAN_SANITIZE_LEAKS
+ lsan_parser.ParseStringFromEnv("LSAN_OPTIONS");
+#endif
#if HWASAN_CONTAINS_UBSAN
ubsan_parser.ParseStringFromEnv("UBSAN_OPTIONS");
#endif
@@ -133,6 +147,12 @@ static void InitializeFlags() {
if (Verbosity()) ReportUnrecognizedFlags();
if (common_flags()->help) parser.PrintFlagDescriptions();
+ // Flag validation:
+ if (!CAN_SANITIZE_LEAKS && common_flags()->detect_leaks) {
+ Report("%s: detect_leaks is not supported on this platform.\n",
+ SanitizerToolName);
+ Die();
+ }
}
static void CheckUnwind() {
More information about the llvm-commits
mailing list