Use __msan_check_mem_is_initialized for detailed MSan report
This replaces the __msan_test_shadow introduced in "Validate absl::StringResizeAndOverwrite op has written bytes as expected." with __msan_check_mem_is_initialized, because the __msan_test_shadow assertion gives terse output ("false && shadow == -1") and cannot benefit from MSan's track origins mode.
PiperOrigin-RevId: 822786851
Change-Id: I8927521b5c38a7491f3b4e77e479014bba75cb36
diff --git a/absl/strings/resize_and_overwrite.h b/absl/strings/resize_and_overwrite.h
index b3bd06e..91df897 100644
--- a/absl/strings/resize_and_overwrite.h
+++ b/absl/strings/resize_and_overwrite.h
@@ -177,8 +177,7 @@
}
#endif
#if defined(ABSL_HAVE_MEMORY_SANITIZER)
- auto shadow = __msan_test_shadow(str.data(), str.size());
- ABSL_ASSERT(shadow == -1);
+ __msan_check_mem_is_initialized(str.data(), str.size());
#endif
}
diff --git a/absl/strings/resize_and_overwrite_test.cc b/absl/strings/resize_and_overwrite_test.cc
index 8adad2c..1070dec 100644
--- a/absl/strings/resize_and_overwrite_test.cc
+++ b/absl/strings/resize_and_overwrite_test.cc
@@ -119,7 +119,8 @@
if (param.initial_size < param.final_size) {
#ifndef NDEBUG
- EXPECT_DEATH_IF_SUPPORTED(op(), "shadow == -1");
+ EXPECT_DEATH_IF_SUPPORTED(op(),
+ "MemorySanitizer: use-of-uninitialized-value");
#endif
} else {
// The string is fully initialized from the initial constructor, or we skip