From 1127fb98567697447a5214a53409b5b84400d165 Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Tue, 5 Jun 2018 21:44:50 +0200 Subject: [PATCH] Re-enabling SanitizerTest.MsanUninitialized. Using EXPECT_DEATH instead of __msan_set_expect_umr. Bug: webrtc:9116 Change-Id: I40222e920cd213d3d1366629023d4d1c4fbc35f9 Reviewed-on: https://webrtc-review.googlesource.com/79661 Reviewed-by: Karl Wiberg Reviewed-by: Alessio Bazzica Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/master@{#23532} --- rtc_base/sanitizer_unittest.cc | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/rtc_base/sanitizer_unittest.cc b/rtc_base/sanitizer_unittest.cc index 21ef432fb3..8dc606802f 100644 --- a/rtc_base/sanitizer_unittest.cc +++ b/rtc_base/sanitizer_unittest.cc @@ -122,28 +122,20 @@ struct Bar { Foo foo; }; -// Run the callback, and crash if it *doesn't* make an uninitialized memory -// read. If MSan isn't on, just run the callback. +// Run the callback, and expect a crash if it *doesn't* make an uninitialized +// memory read. If MSan isn't on, just run the callback. template void MsanExpectUninitializedRead(F&& f) { #if RTC_HAS_MSAN - // Allow uninitialized memory reads. - RTC_LOG(LS_INFO) << "__msan_set_expect_umr(1)"; - __msan_set_expect_umr(1); -#endif + EXPECT_DEATH(f(), ""); +#else f(); -#if RTC_HAS_MSAN - // Disallow uninitialized memory reads again, and verify that at least - // one uninitialized memory read happened while we weren't looking. - RTC_LOG(LS_INFO) << "__msan_set_expect_umr(0)"; - __msan_set_expect_umr(0); #endif } } // namespace -// TODO(b/9116): Enable the test when the bug is fixed. -TEST(SanitizerTest, DISABLED_MsanUninitialized) { +TEST(SanitizerTest, MsanUninitialized) { Bar bar = MsanUninitialized({}); // Check that a read after initialization is OK. bar.ID = 1;