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 <kwiberg@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23532}
This commit is contained in:

committed by
Commit Bot

parent
b544f6c2f5
commit
1127fb9856
@ -122,28 +122,20 @@ struct Bar {
|
|||||||
Foo foo;
|
Foo foo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run the callback, and crash if it *doesn't* make an uninitialized memory
|
// Run the callback, and expect a crash if it *doesn't* make an uninitialized
|
||||||
// read. If MSan isn't on, just run the callback.
|
// memory read. If MSan isn't on, just run the callback.
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void MsanExpectUninitializedRead(F&& f) {
|
void MsanExpectUninitializedRead(F&& f) {
|
||||||
#if RTC_HAS_MSAN
|
#if RTC_HAS_MSAN
|
||||||
// Allow uninitialized memory reads.
|
EXPECT_DEATH(f(), "");
|
||||||
RTC_LOG(LS_INFO) << "__msan_set_expect_umr(1)";
|
#else
|
||||||
__msan_set_expect_umr(1);
|
|
||||||
#endif
|
|
||||||
f();
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// TODO(b/9116): Enable the test when the bug is fixed.
|
TEST(SanitizerTest, MsanUninitialized) {
|
||||||
TEST(SanitizerTest, DISABLED_MsanUninitialized) {
|
|
||||||
Bar bar = MsanUninitialized<Bar>({});
|
Bar bar = MsanUninitialized<Bar>({});
|
||||||
// Check that a read after initialization is OK.
|
// Check that a read after initialization is OK.
|
||||||
bar.ID = 1;
|
bar.ID = 1;
|
||||||
|
Reference in New Issue
Block a user