summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 08:33:06 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 08:33:06 +0000
commit55e00e62c98889d0d7b45948e81d9ba48e3e9df6 (patch)
treed96cbfcd5ed15f330fc99f8caf79a3f83b29ff55 /skia
parent56a9ecef6a6a2bdd32a3e85fc30b9403de8e98c8 (diff)
downloadchromium_src-55e00e62c98889d0d7b45948e81d9ba48e3e9df6.zip
chromium_src-55e00e62c98889d0d7b45948e81d9ba48e3e9df6.tar.gz
chromium_src-55e00e62c98889d0d7b45948e81d9ba48e3e9df6.tar.bz2
Add diagnostic information for CreateDIBSection failures
This tries to grab useful diagnostic information from the system when CreateDIBSection fails since we're about to crash anyway. This tries to categorize the failure as being out of GDI handles, out of memory generally, or unknown and puts more information on the stack. Based on code from cpu@ in r116646 and from vangelis@ in https://codereview.chromium.org/57053002/ R=cpu TBR=reed NOTRY=true since nacl_integration is being stupid BUG=275046 Review URL: https://codereview.chromium.org/70193011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/bitmap_platform_device_win.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/skia/ext/bitmap_platform_device_win.cc b/skia/ext/bitmap_platform_device_win.cc
index 203281d..42f431b 100644
--- a/skia/ext/bitmap_platform_device_win.cc
+++ b/skia/ext/bitmap_platform_device_win.cc
@@ -5,6 +5,8 @@
#include <windows.h>
#include <psapi.h>
+#include "base/logging.h"
+#include "base/debug/alias.h"
#include "skia/ext/bitmap_platform_device_win.h"
#include "skia/ext/bitmap_platform_device_data.h"
#include "skia/ext/platform_canvas.h"
@@ -57,6 +59,62 @@ HBITMAP CreateHBitmap(int width, int height, bool is_opaque,
HBITMAP hbitmap = CreateDIBSection(NULL, reinterpret_cast<BITMAPINFO*>(&hdr),
0, data, shared_section, 0);
+
+ // If this call fails, we're gonna crash hard. Try to get some useful
+ // information out before we crash for post-mortem analysis.
+ if (!hbitmap) {
+ // Make sure parameters are saved in the minidump.
+ base::debug::Alias(&width);
+ base::debug::Alias(&height);
+
+ int last_error = GetLastError();
+ base::debug::Alias(&last_error);
+
+ int num_gdi_handles = GetGuiResources(GetCurrentProcess(),
+ GR_GDIOBJECTS);
+ if (num_gdi_handles == 0) {
+ int get_gui_resources_error = GetLastError();
+ base::debug::Alias(&get_gui_resources_error);
+ CHECK(false);
+ }
+
+ base::debug::Alias(&num_gdi_handles);
+ const int kLotsOfHandles = 9990;
+ if (num_gdi_handles > kLotsOfHandles)
+ CHECK(false);
+
+ PROCESS_MEMORY_COUNTERS_EX pmc;
+ pmc.cb = sizeof(pmc);
+ if (!GetProcessMemoryInfo(GetCurrentProcess(),
+ reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&pmc),
+ sizeof(pmc))) {
+ CHECK(false);
+ }
+ const size_t kLotsOfMemory = 1500 * 1024 * 1024; // 1.5GB
+ if (pmc.PagefileUsage > kLotsOfMemory)
+ CHECK(false);
+ if (pmc.PrivateUsage > kLotsOfMemory)
+ CHECK(false);
+
+ // Huh, that's weird. We don't have crazy handle count, we don't have
+ // ridiculous memory usage. Try to allocate a small bitmap and see if that
+ // fails too.
+ hdr.biWidth = 5;
+ hdr.biHeight = 5;
+ void* small_data;
+ HBITMAP small_bitmap = CreateDIBSection(
+ NULL, reinterpret_cast<BITMAPINFO*>(&hdr),
+ 0, &small_data, shared_section, 0);
+ if (!small_bitmap)
+ CHECK(false);
+ BITMAP bitmap_data;
+ if (GetObject(small_bitmap, sizeof(BITMAP), &bitmap_data)) {
+ if (!DeleteObject(small_bitmap))
+ CHECK(false);
+ }
+ // No idea what's going on. Die!
+ CHECK(false);
+ }
return hbitmap;
}