Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(724)

Unified Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 9803002: [windows] Make calls to exit(), _exit(), abort(), and ExitProcess() from the renderer process resul… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase just in case.... Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..57acbe96a038b9023fc790e5accec3b52323d530 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>
brettw 2012/03/23 21:16:37 I'd put this after the first header file.
eroman 2012/03/23 21:26:23 Done.
+
#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,28 @@ void SkiaPreCacheFont(LOGFONT logfont) {
}
}
+void __cdecl ForceCrashOnAbort(int) {
brettw 2012/03/23 21:16:37 Can you call this ...SigAbort or something? At fir
eroman 2012/03/23 21:26:23 Done.
+ *((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.
+ // 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, ForceCrashOnAbort);
+}
+
} // namespace
RendererMainPlatformDelegate::RendererMainPlatformDelegate(
@@ -81,6 +106,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 +127,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) {
« no previous file with comments | « chrome/app/breakpad_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698