summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 21:44:52 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-07 21:44:52 +0000
commit88791a8ce288cf80530911c7aae663cf71f84961 (patch)
treeb7f51fe45b38082e8affbda67e12c419f3032408 /chrome
parent18e264be38a945d0a82b384a72a7dd8f5169392e (diff)
downloadchromium_src-88791a8ce288cf80530911c7aae663cf71f84961.zip
chromium_src-88791a8ce288cf80530911c7aae663cf71f84961.tar.gz
chromium_src-88791a8ce288cf80530911c7aae663cf71f84961.tar.bz2
Stick tcmalloc heap stats on the stack before crashing due to OOM
This should make diagnosing OOM crashes a lot easier. TEST=manually force OOM, check the stack BUG=29351 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=33878 (reverted at 33879) Review URL: http://codereview.chromium.org/462030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33993 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chrome_dll_main.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index 5d58d6e..3531e80 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -80,6 +80,10 @@
#include "tools/memory_watcher/memory_watcher.h"
#endif
+#if defined(USE_TCMALLOC)
+#include "third_party/tcmalloc/chromium/src/google/malloc_extension.h"
+#endif
+
extern int BrowserMain(const MainFunctionParams&);
extern int RendererMain(const MainFunctionParams&);
extern int PluginMain(const MainFunctionParams&);
@@ -136,13 +140,27 @@ void PureCall() {
__debugbreak();
}
+#pragma warning( push )
+// Disables warning 4748 which is: "/GS can not protect parameters and local
+// variables from local buffer overrun because optimizations are disabled in
+// function." GetStats() will not overflow the passed-in buffer and this
+// function never returns.
+#pragma warning( disable : 4748 )
void OnNoMemory() {
+#if defined(USE_TCMALLOC)
+ // Try to get some information on the stack to make the crash easier to
+ // diagnose from a minidump, being very careful not to do anything that might
+ // try to heap allocate.
+ char buf[32*1024];
+ MallocExtension::instance()->GetStats(buf, sizeof(buf));
+#endif
// Kill the process. This is important for security, since WebKit doesn't
// NULL-check many memory allocations. If a malloc fails, returns NULL, and
// the buffer is then used, it provides a handy mapping of memory starting at
// address 0 for an attacker to utilize.
__debugbreak();
}
+#pragma warning( pop )
// Handlers to silently dump the current process when there is an assert in
// chrome.