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

Unified Diff: base/process/memory_unittest.cc

Issue 2674253003: Populate allocation size into OOM exception on Windows. (Closed)
Patch Set: 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 | base/process/memory_win.cc » ('j') | base/process/memory_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/memory_unittest.cc
diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc
index 0be2d4400633ba75101423e4a452891ddb87d9aa..909905c692045dbdb9bff7472ecdde7f41506cf9 100644
--- a/base/process/memory_unittest.cc
+++ b/base/process/memory_unittest.cc
@@ -409,6 +409,34 @@ class OutOfMemoryHandledTest : public OutOfMemoryTest {
}
};
+#if defined(OS_WIN)
+
+namespace {
+
+DWORD HandleOutOfMemoryException(EXCEPTION_POINTERS* exception_ptrs,
+ size_t expected_size) {
+ EXPECT_EQ(base::win::kOomExceptionCode,
+ exception_ptrs->ExceptionRecord->ExceptionCode);
+ EXPECT_LE(1U, exception_ptrs->ExceptionRecord->NumberParameters);
+ EXPECT_EQ(expected_size,
+ exception_ptrs->ExceptionRecord->ExceptionInformation[0]);
+ return EXCEPTION_EXECUTE_HANDLER;
+}
+
+} // namespace
+
+TEST_F(OutOfMemoryTest, TerminateBecauseOutOfMemoryReportsAllocSize) {
+ // On Windows, TerminateBecauseOutOfMemory reports the attempted allocation
+ // size in the exception raised.
+ const size_t kAttemptedAllocationSize = 0xBADA55;
Will Harris 2017/02/06 18:24:03 Can you test with a value that does not fit in 32b
Sigurður Ásgeirsson 2017/02/06 19:43:58 Done.
+ __try {
+ base::TerminateBecauseOutOfMemory(kAttemptedAllocationSize);
+ } __except (HandleOutOfMemoryException(GetExceptionInformation(),
+ kAttemptedAllocationSize)) {
+ }
+}
+#endif // OS_WIN
+
// TODO(b.kelemen): make UncheckedMalloc and UncheckedCalloc work
// on Windows as well.
TEST_F(OutOfMemoryHandledTest, UncheckedMalloc) {
« no previous file with comments | « no previous file | base/process/memory_win.cc » ('j') | base/process/memory_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698