Chromium Code Reviews| Index: content/renderer/renderer_main_platform_delegate_win.cc |
| diff --git a/content/renderer/renderer_main_platform_delegate_win.cc b/content/renderer/renderer_main_platform_delegate_win.cc |
| index b7de8fa4991652e21b51f9d9116555c5526766d0..50561b57e3aee99372205411e79be7d741c3b46d 100644 |
| --- a/content/renderer/renderer_main_platform_delegate_win.cc |
| +++ b/content/renderer/renderer_main_platform_delegate_win.cc |
| @@ -2,11 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <signal.h> |
| + |
| #include "content/renderer/renderer_main_platform_delegate.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/win/win_util.h" |
| #include "content/common/injection_test_dll.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/renderer/render_thread.h" |
| @@ -69,6 +72,25 @@ void SkiaPreCacheFont(LOGFONT logfont) { |
| } |
| } |
| +void __cdecl ForceCrashOnAbort(int) { |
| + *((int*)0) = 0x1337; |
| +} |
| + |
| +void InitExitInterceptions() { |
| + // If code subsequently tries to exit using exit(), _exit(), abort(), or |
| + // ExitProcess(), force a crash (since otherwise these would be silent |
| + // terminations and fly under the radar). |
| + base::win::SetShouldCrashOnProcessDetach(true); |
| + |
| + // Prevent CRT's abort code from prompting a dialog or trying to "report" it. |
| + // Also disable the_CALL_REPORTFAULT behavior, since it has the sideffect of |
|
rvargas (doing something else)
2012/03/22 02:55:59
nit: the <space> _CALL_RE...
eroman
2012/03/22 04:30:23
Done.
|
| + // clearing our exception filter, which means we don't get any crash. |
| + _set_abort_behavior(0, _WRITE_ABORT_MSG); |
| + _set_abort_behavior(0, _CALL_REPORTFAULT); |
|
rvargas (doing something else)
2012/03/22 02:55:59
_set_abort_bahavior(0, _WRITE_A_M | _CALL_R); ? (I
eroman
2012/03/22 04:30:23
Done.
|
| + |
| + signal(SIGABRT, ForceCrashOnAbort); |
| +} |
| + |
| } // namespace |
| RendererMainPlatformDelegate::RendererMainPlatformDelegate( |
| @@ -81,6 +103,8 @@ RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { |
| } |
| void RendererMainPlatformDelegate::PlatformInitialize() { |
| + InitExitInterceptions(); |
| + |
| // Be mindful of what resources you acquire here. They can be used by |
| // malicious code if the renderer gets compromised. |
| const CommandLine& command_line = parameters_.command_line; |
| @@ -100,6 +124,9 @@ void RendererMainPlatformDelegate::PlatformInitialize() { |
| } |
| void RendererMainPlatformDelegate::PlatformUninitialize() { |
| + // At this point we are shutting down in a normal code path, so undo our |
| + // hack to crash on exit. |
| + base::win::SetShouldCrashOnProcessDetach(false); |
| } |
| bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { |