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

Unified Diff: base/process/memory_unittest.cc

Issue 2674253003: Populate allocation size into OOM exception on Windows. (Closed)
Patch Set: Address Will's comment. 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') | no next file with comments »
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..ce28225d3f5bc709a524e517e9990eb4efd8156d 100644
--- a/base/process/memory_unittest.cc
+++ b/base/process/memory_unittest.cc
@@ -409,6 +409,40 @@ 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.
+#if defined(ARCH_CPU_64_BITS)
+ // Test with a size larger than 32 bits on 64 bit machines.
+ const size_t kAttemptedAllocationSize = 0xBADA55F00DULL;
+#else
+ const size_t kAttemptedAllocationSize = 0xBADA55;
+#endif
+
+ __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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698