[compiler-rt] [Sanitizer] Call Die() instead of Abort() when failed to reserve shadow memory range (PR #107833)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 02:55:45 PDT 2024


https://github.com/Enna1 created https://github.com/llvm/llvm-project/pull/107833

I grep the code and find that `Abort()` is only called in `Die()` when the flag `abort_on_error` is set.
Thus, if reserving shadow memory range fails, `Die()` rather than `Abort()` should be called. In this case, the flag `abort_on_error` will be respected and the die callbacks will be called.

>From d54fad87f7868d347ce2c41c771e14c15a0fd5d7 Mon Sep 17 00:00:00 2001
From: "xumingjie.enna1" <xumingjie.enna1 at bytedance.com>
Date: Mon, 9 Sep 2024 17:17:13 +0800
Subject: [PATCH] [Sanitizer] Call Die() instead of Abort() when failed to
 reserve shadow memory range

I grep the code and find that `Abort()` is only called in `Die()` when the flag `abort_on_error`
is set.
Thus, if reserving shadow memory range fails, `Die()` rather than `Abort()` should
be called. In this case, the flag abort_on_error will be respected and the die callbacks will be called.
---
 compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index 3966d82d51ee96..684720963a8dcb 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -171,7 +171,7 @@ void ReserveShadowMemoryRange(uptr beg, uptr end, const char *name,
         "ReserveShadowMemoryRange failed while trying to map 0x%zx bytes. "
         "Perhaps you're using ulimit -v or ulimit -d\n",
         size);
-    Abort();
+    Die();
   }
   if (madvise_shadow && common_flags()->use_madv_dontdump)
     DontDumpShadowMemory(beg, size);



More information about the llvm-commits mailing list