OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/child/child_thread_impl.h" | 5 #include "content/child/child_thread_impl.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 const int kConnectionTimeoutS = 15; | 72 const int kConnectionTimeoutS = 15; |
73 | 73 |
74 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = | 74 base::LazyInstance<base::ThreadLocalPointer<ChildThreadImpl> > g_lazy_tls = |
75 LAZY_INSTANCE_INITIALIZER; | 75 LAZY_INSTANCE_INITIALIZER; |
76 | 76 |
77 // This isn't needed on Windows because there the sandbox's job object | 77 // This isn't needed on Windows because there the sandbox's job object |
78 // terminates child processes automatically. For unsandboxed processes (i.e. | 78 // terminates child processes automatically. For unsandboxed processes (i.e. |
79 // plugins), PluginThread has EnsureTerminateMessageFilter. | 79 // plugins), PluginThread has EnsureTerminateMessageFilter. |
80 #if defined(OS_POSIX) | 80 #if defined(OS_POSIX) |
81 | 81 |
82 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 | 82 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
83 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ | 83 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ |
84 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ | 84 defined(UNDEFINED_SANITIZER) |
85 defined(UNDEFINED_SANITIZER)) && !defined(OS_CHROMEOS) | |
86 // A thread delegate that waits for |duration| and then exits the process with | 85 // A thread delegate that waits for |duration| and then exits the process with |
87 // _exit(0). | 86 // _exit(0). |
88 class WaitAndExitDelegate : public base::PlatformThread::Delegate { | 87 class WaitAndExitDelegate : public base::PlatformThread::Delegate { |
89 public: | 88 public: |
90 explicit WaitAndExitDelegate(base::TimeDelta duration) | 89 explicit WaitAndExitDelegate(base::TimeDelta duration) |
91 : duration_(duration) {} | 90 : duration_(duration) {} |
92 | 91 |
93 void ThreadMain() override { | 92 void ThreadMain() override { |
94 base::PlatformThread::Sleep(duration_); | 93 base::PlatformThread::Sleep(duration_); |
95 _exit(0); | 94 _exit(0); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // from the IPC sender) are routed to the main message loop but never | 129 // from the IPC sender) are routed to the main message loop but never |
131 // processed (because that message loop is stuck in V8). | 130 // processed (because that message loop is stuck in V8). |
132 // | 131 // |
133 // One could make the browser SIGKILL the renderers, but that leaves open a | 132 // One could make the browser SIGKILL the renderers, but that leaves open a |
134 // large window where a browser failure (or a user, manually terminating | 133 // large window where a browser failure (or a user, manually terminating |
135 // the browser because "it's stuck") will leave behind a process eating all | 134 // the browser because "it's stuck") will leave behind a process eating all |
136 // the CPU. | 135 // the CPU. |
137 // | 136 // |
138 // So, we install a filter on the sender so that we can process this event | 137 // So, we install a filter on the sender so that we can process this event |
139 // here and kill the process. | 138 // here and kill the process. |
140 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 | 139 #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
141 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ | 140 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ |
142 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \ | 141 defined(UNDEFINED_SANITIZER) |
143 defined(UNDEFINED_SANITIZER)) && !defined(OS_CHROMEOS) | |
144 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection, | 142 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection, |
145 // or dump code coverage data to disk). Instead of exiting the process | 143 // or dump code coverage data to disk). Instead of exiting the process |
146 // immediately, we give it 60 seconds to run exit handlers. | 144 // immediately, we give it 60 seconds to run exit handlers. |
147 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60))); | 145 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60))); |
148 #if defined(LEAK_SANITIZER) | 146 #if defined(LEAK_SANITIZER) |
149 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If | 147 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If |
150 // leaks are found, the process will exit here. | 148 // leaks are found, the process will exit here. |
151 __lsan_do_leak_check(); | 149 __lsan_do_leak_check(); |
152 #endif | 150 #endif |
153 #else | 151 #else |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 | 632 |
635 void ChildThreadImpl::OnProcessBackgrounded(bool background) { | 633 void ChildThreadImpl::OnProcessBackgrounded(bool background) { |
636 // Set timer slack to maximum on main thread when in background. | 634 // Set timer slack to maximum on main thread when in background. |
637 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 635 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
638 if (background) | 636 if (background) |
639 timer_slack = base::TIMER_SLACK_MAXIMUM; | 637 timer_slack = base::TIMER_SLACK_MAXIMUM; |
640 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 638 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
641 } | 639 } |
642 | 640 |
643 } // namespace content | 641 } // namespace content |
OLD | NEW |