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

Unified Diff: base/process/memory_win.cc

Issue 2173463002: Make base::TerminateBecauseOutOfMemory call RaiseException on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittests Created 4 years, 5 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 | « base/process/memory_unittest.cc ('k') | skia/ext/SkMemory_new_handler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/memory_win.cc
diff --git a/base/process/memory_win.cc b/base/process/memory_win.cc
index 9d75efecacb21af8e9afbb857a1b560fa6c3f171..bf0c2c2e3c5bb0a691481dbbdea429bfb83e2850 100644
--- a/base/process/memory_win.cc
+++ b/base/process/memory_win.cc
@@ -32,23 +32,31 @@ namespace {
#pragma warning(disable: 4702)
int OnNoMemory(size_t size) {
+ // Custom exception code chosen to indicate an out of memory error.
+ // See https://msdn.microsoft.com/en-us/library/het71c37.aspx.
+ // "To make sure that you do not define a code that conflicts with an existing
+ // exception code" ... "The resulting error code should therefore have the
+ // highest four bits set to hexadecimal E."
+ // 0xe0000008 was chosen arbitrarily as 0x00000008 is ERROR_NOT_ENOUGH_MEMORY.
+ const DWORD kOomExceptionCode = 0xe0000008;
Mark Mentovai 2016/07/21 21:15:11 Now you’ve got to update the comment in Breakpad t
+
// Kill the process. This is important for security since most of code
// does not check the result of memory allocation.
// https://msdn.microsoft.com/en-us/library/het71c37.aspx
- ::RaiseException(win::kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0,
- nullptr);
+ ::RaiseException(kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0, nullptr);
// Safety check, make sure process exits here.
- _exit(win::kOomExceptionCode);
+ _exit(kOomExceptionCode);
return 0;
}
#pragma warning(pop)
-// HeapSetInformation function pointer.
-typedef BOOL (WINAPI* HeapSetFn)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T);
-
} // namespace
+void TerminateBecauseOutOfMemory(size_t size) {
+ OnNoMemory(size);
+}
+
void EnableTerminationOnHeapCorruption() {
// Ignore the result code. Supported on XP SP3 and Vista.
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
« no previous file with comments | « base/process/memory_unittest.cc ('k') | skia/ext/SkMemory_new_handler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698