[compiler-rt] [llvm] [msan] Automatically print shadow for failing outlined checks (PR #145107)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 20 16:12:04 PDT 2025
================
@@ -352,23 +352,70 @@ void __sanitizer::BufferedStackTrace::UnwindImpl(
using namespace __msan;
-#define MSAN_MAYBE_WARNING(type, size) \
- void __msan_maybe_warning_##size(type s, u32 o) { \
- GET_CALLER_PC_BP; \
- if (UNLIKELY(s)) { \
- PrintWarningWithOrigin(pc, bp, o); \
- if (__msan::flags()->halt_on_error) { \
- Printf("Exiting\n"); \
- Die(); \
- } \
- } \
+// N.B. Only [shadow, shadow+size) is defined. shadow is *not* a pointer into
+// an MSan shadow region.
+static void print_shadow_value(void *shadow, u64 size) {
+ Printf("\n");
+ Printf("Shadow value (%llu byte%s):", size, size == 1 ? "" : "s");
+ for (unsigned int i = 0; i < size; i++) {
+ if (i % 4 == 0)
+ Printf(" ");
+
+ unsigned char x = ((unsigned char *)shadow)[i];
+ Printf("%x%x", x >> 4, x & 0xf);
+ }
+ Printf("\n");
+ Printf(
+ "Caveat: the shadow value does not necessarily directly correspond to a "
+ "single user variable. The correspondence is stronger, but not always "
+ "perfect, when origin tracking is enabled.\n");
+ Printf("\n");
+}
+
+#define MSAN_MAYBE_WARNING(type, size) \
+ void __msan_maybe_warning_##size(type s, u32 o) { \
+ GET_CALLER_PC_BP; \
+ \
+ if (UNLIKELY(s)) { \
+ PrintWarningWithOrigin(pc, bp, o); \
+ if (Verbosity() >= 1) \
----------------
thurstond wrote:
Done: https://github.com/llvm/llvm-project/pull/145107/commits/338bccd3d82a344f00d8e05ac79baf66b99c41af
https://github.com/llvm/llvm-project/pull/145107
More information about the llvm-commits
mailing list