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

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: fix sorting 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..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) {
« 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