summaryrefslogtreecommitdiffstats
path: root/chrome/app
diff options
context:
space:
mode:
authormaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-31 13:19:11 +0000
committermaruel@google.com <maruel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-31 13:19:11 +0000
commitd0abe5441d5a1f4e29121b4ec68f781090bef5a1 (patch)
tree6c9347c0e7cefe0f99fd6bb177dcdf1dfa42a4ba /chrome/app
parent7e0e876b16395b6aa4aa6868434d18ef975e4ae0 (diff)
downloadchromium_src-d0abe5441d5a1f4e29121b4ec68f781090bef5a1.zip
chromium_src-d0abe5441d5a1f4e29121b4ec68f781090bef5a1.tar.gz
chromium_src-d0abe5441d5a1f4e29121b4ec68f781090bef5a1.tar.bz2
Trap all malloc/new allocation failures in chrome.dll at allocation point. This won't fix the failure but this will help classifying minidumps.
BUG=1298132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app')
-rw-r--r--chrome/app/chrome_main.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc
index 8390b66..54cb57c 100644
--- a/chrome/app/chrome_main.cc
+++ b/chrome/app/chrome_main.cc
@@ -30,6 +30,7 @@
#include <atlbase.h>
#include <atlapp.h>
#include <malloc.h>
+#include <new.h>
#include "base/command_line.h"
#include "base/icu_util.h"
@@ -88,6 +89,14 @@ void PureCall() {
__debugbreak();
}
+int OnNoMemory(size_t memory_size) {
+ __debugbreak();
+ // Return memory_size so it is not optimized out. Make sure the return value
+ // is at least 1 so malloc/new is retried, especially useful when under a
+ // debugger.
+ return memory_size ? static_cast<int>(memory_size) : 1;
+}
+
// Handlers to silently dump the current process when there is an assert in
// chrome.
void ChromeAssert(const std::string& str) {
@@ -135,6 +144,10 @@ DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
// notify breakpad when it happens.
_set_invalid_parameter_handler(InvalidParameter);
_set_purecall_handler(PureCall);
+ // Gather allocation failure.
+ _set_new_handler(&OnNoMemory);
+ // Make sure malloc() calls the new handler too.
+ _set_new_mode(1);
CommandLine parsed_command_line;