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

Unified Diff: content/renderer/render_thread_impl.cc

Issue 10027027: Moved SuicideOnChannelErrorFilter to content. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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/renderer/chrome_render_process_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 19905c69dd0261e064ad836c06151e4767b1eee2..967db0acfc18d0d7968a2410d13754f11f321c28 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -179,6 +179,30 @@ RenderThreadImpl::RenderThreadImpl(const std::string& channel_name)
Init();
}
+#if defined(OS_POSIX)
+class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
+ void OnChannelError() {
+ // On POSIX, at least, one can install an unload handler which loops
+ // forever and leave behind a renderer process which eats 100% CPU forever.
+ //
+ // This is because the terminate signals (ViewMsg_ShouldClose and the error
+ // from the IPC channel) are routed to the main message loop but never
+ // processed (because that message loop is stuck in V8).
+ //
+ // One could make the browser SIGKILL the renderers, but that leaves open a
+ // large window where a browser failure (or a user, manually terminating
+ // the browser because "it's stuck") will leave behind a process eating all
+ // the CPU.
+ //
+ // So, we install a filter on the channel so that we can process this event
+ // here and kill the process.
+
+ _exit(0);
+ }
+};
+#endif // OS_POSIX
+
+
void RenderThreadImpl::Init() {
TRACE_EVENT_BEGIN_ETW("RenderThreadImpl::Init", 0, "");
@@ -232,6 +256,10 @@ void RenderThreadImpl::Init() {
AddFilter(new IndexedDBMessageFilter);
+#if defined(OS_POSIX)
+ AddFilter(new SuicideOnChannelErrorFilter());
+#endif
+
content::GetContentClient()->renderer()->RenderThreadStarted();
// Note that under Linux, the media library will normally already have
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698