Index: base/win/win_util.cc |
diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
index 3b6b1761ed3199ab34008fde4e1f584a72da9cea..b885d6ea7bd9d0e15275f5a55c6a56ee4b846f0f 100644 |
--- a/base/win/win_util.cc |
+++ b/base/win/win_util.cc |
@@ -11,6 +11,8 @@ |
#include <propvarutil.h> |
#include <sddl.h> |
#include <shlobj.h> |
+#include <signal.h> |
+#include <stdlib.h> |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
@@ -39,6 +41,10 @@ bool SetPropVariantValueForPropertyStore( |
return SUCCEEDED(result); |
} |
+void __cdecl ForceCrashOnSigAbort(int) { |
+ *((int*)0) = 0x1337; |
+} |
+ |
} // namespace |
namespace base { |
@@ -186,6 +192,19 @@ bool ShouldCrashOnProcessDetach() { |
return g_crash_on_process_detach; |
} |
+void SetAbortBehaviorForCrashReporting() { |
+ // Prevent CRT's abort code from prompting a dialog or trying to "report" it. |
+ // Disabling the _CALL_REPORTFAULT behavior is important since otherwise it |
+ // has the sideffect of clearing our exception filter, which means we |
+ // don't get any crash. |
+ _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); |
+ |
+ // Set a SIGABRT handler for good measure. We will crash even if the default |
+ // is left in place, however this allows us to crash earlier. And it also |
+ // lets us crash in response to code which might directly call raise(SIGABRT) |
+ signal(SIGABRT, ForceCrashOnSigAbort); |
+} |
+ |
bool IsMachineATablet() { |
if (base::win::GetVersion() < base::win::VERSION_WIN7) |
return false; |