/* * Copyright 2018 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// 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 <typename F> void MsanExpectUninitializedRead(F&& f) { #if RTC_HAS_MSAN
EXPECT_DEATH(f(), ""); #else
f(); #endif
}
} // namespace
TEST(SanitizerTest, MsanUninitialized) {
Bar bar = MsanUninitialized<Bar>({}); // Check that a read after initialization is OK.
bar.ID = 1;
EXPECT_EQ(1u, bar.ID);
RTC_LOG(LS_INFO) << "read after init passed"; // Check that other fields are uninitialized and equal to zero.
MsanExpectUninitializedRead([&] { EXPECT_EQ(0u, bar.foo.field1); });
MsanExpectUninitializedRead([&] { EXPECT_EQ(0u, bar.foo.field2); });
RTC_LOG(LS_INFO) << "read with no init passed";
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.