Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: base/security_unittest.cc

Issue 2692313002: Reland of nable SecurityTest.NewOverflow on Windows, with clang fix (Closed)
Patch Set: no asan Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/security_unittest.cc
diff --git a/base/security_unittest.cc b/base/security_unittest.cc
index af9d2bf19d3a52b15a53fdbd1032afe639336fac..d5637bbf83a802e38991f4cbdc00c03dcbfbef81 100644
--- a/base/security_unittest.cc
+++ b/base/security_unittest.cc
@@ -87,31 +87,31 @@ void OverflowTestsSoftExpectTrue(bool overflow_detected) {
}
}
-#if defined(OS_IOS) || defined(OS_WIN) || defined(OS_LINUX)
+#if defined(OS_IOS) || defined(OS_LINUX) || defined(ADDRESS_SANITIZER)
#define MAYBE_NewOverflow DISABLED_NewOverflow
#else
#define MAYBE_NewOverflow NewOverflow
#endif
// Test array[TooBig][X] and array[X][TooBig] allocations for int overflows.
// IOS doesn't honor nothrow, so disable the test there.
-// Crashes on Windows Dbg builds, disable there as well.
// Disabled on Linux because failing Linux Valgrind bot, and Valgrind exclusions
// are not currently read. See http://crbug.com/582398
+// Disabled under ASan because asan aborts when new returns nullptr,
+// https://bugs.chromium.org/p/chromium/issues/detail?id=690271#c15
TEST(SecurityTest, MAYBE_NewOverflow) {
const size_t kArraySize = 4096;
// We want something "dynamic" here, so that the compiler doesn't
// immediately reject crazy arrays.
const size_t kDynamicArraySize = HideValueFromCompiler(kArraySize);
- // numeric_limits are still not constexpr until we switch to C++11, so we
- // use an ugly cast.
- const size_t kMaxSizeT = ~static_cast<size_t>(0);
- ASSERT_EQ(numeric_limits<size_t>::max(), kMaxSizeT);
+ const size_t kMaxSizeT = std::numeric_limits<size_t>::max();
const size_t kArraySize2 = kMaxSizeT / kArraySize + 10;
const size_t kDynamicArraySize2 = HideValueFromCompiler(kArraySize2);
{
std::unique_ptr<char[][kArraySize]> array_pointer(
new (nothrow) char[kDynamicArraySize2][kArraySize]);
- OverflowTestsSoftExpectTrue(!array_pointer);
+ // Prevent clang from optimizing away the whole test.
+ char* volatile p = reinterpret_cast<char*>(array_pointer.get());
+ OverflowTestsSoftExpectTrue(!p);
}
// On windows, the compiler prevents static array sizes of more than
// 0x7fffffff (error C2148).
@@ -121,7 +121,9 @@ TEST(SecurityTest, MAYBE_NewOverflow) {
{
std::unique_ptr<char[][kArraySize2]> array_pointer(
new (nothrow) char[kDynamicArraySize][kArraySize2]);
- OverflowTestsSoftExpectTrue(!array_pointer);
+ // Prevent clang from optimizing away the whole test.
+ char* volatile p = reinterpret_cast<char*>(array_pointer.get());
+ OverflowTestsSoftExpectTrue(!p);
}
#endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698