Bug 761859 - Reinstate a __debugbreak() at the start of MOZ_CRASH() on Windows so that deliberate crashes on Windows appear as breakpoints, not invalid writes. r=bsmedberg
authorJeff Walden <jwalden@mit.edu>
Mon, 18 Jun 2012 12:01:57 -0700
changeset 96958 229623f7ea72ed9e611933ef7c6982d0b44add28
parent 96957 01844720b147314475896425f6c5ae9e6f363053
child 96959 b179d721bcb7b7297048919d9bd399edd21fa5c2
push id22949
push useremorley@mozilla.com
push dateTue, 19 Jun 2012 08:15:37 +0000
treeherdermozilla-central@19bfe36cace8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs761859
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 761859 - Reinstate a __debugbreak() at the start of MOZ_CRASH() on Windows so that deliberate crashes on Windows appear as breakpoints, not invalid writes. r=bsmedberg
mfbt/Assertions.h
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -110,26 +110,35 @@ extern "C" {
  * way, in both debug and release builds.
  *
  * MOZ_CRASH is a good solution for "handling" failure cases when you're
  * unwilling or unable to handle them more cleanly -- for OOM, for likely memory
  * corruption, and so on.  It's also a good solution if you need safe behavior
  * in release builds as well as debug builds.  But if the failure is one that
  * should be debugged and fixed, MOZ_ASSERT is generally preferable.
  */
-#ifdef WIN32
+#if defined(_MSC_VER)
+   /*
+    * On MSVC use the __debugbreak compiler intrinsic, which produces an inline
+    * (not nested in a system function) breakpoint.  This distinctively invokes
+    * Breakpad without requiring system library symbols on all stack-processing
+    * machines, as a nested breakpoint would require.  (Technically all Windows
+    * compilers would require this, but practically only MSVC matters.)
+    */
 #  ifdef __cplusplus
 #    define MOZ_CRASH() \
        do { \
+         __debugbreak(); \
          *((volatile int*) NULL) = 123; \
          ::exit(3); \
        } while (0)
 #  else
 #    define MOZ_CRASH() \
        do { \
+         __debugbreak(); \
          *((volatile int*) NULL) = 123; \
          exit(3); \
        } while (0)
 #  endif
 #else
 #  ifdef __cplusplus
 #    define MOZ_CRASH() \
        do { \