From c3af62bc97e3aa9b1a135fcea9b6579e0d209715 Mon Sep 17 00:00:00 2001 From: "jamesr@chromium.org" Date: Fri, 4 Dec 2009 23:03:07 +0000 Subject: 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 Review URL: http://codereview.chromium.org/462030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33878 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/chrome_dll_main.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'chrome/app') diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index e83e07d..651ab1dc 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&); @@ -137,6 +141,13 @@ void PureCall() { } 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 -- cgit v1.1