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

Side by Side Diff: content/child/child_thread.cc

Issue 837633008: Hook UBSAN, MSAN to exit handler(s) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a style nit in old code. Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « content/browser/child_process_launcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "content/child/child_thread.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 base::LazyInstance<base::ThreadLocalPointer<ChildThread> > g_lazy_tls = 74 base::LazyInstance<base::ThreadLocalPointer<ChildThread> > 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 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622
83 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ 83 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
84 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) 84 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
85 defined(UNDEFINED_SANITIZER)) && !defined(OS_CHROMEOS)
85 // A thread delegate that waits for |duration| and then exits the process with 86 // A thread delegate that waits for |duration| and then exits the process with
86 // _exit(0). 87 // _exit(0).
87 class WaitAndExitDelegate : public base::PlatformThread::Delegate { 88 class WaitAndExitDelegate : public base::PlatformThread::Delegate {
88 public: 89 public:
89 explicit WaitAndExitDelegate(base::TimeDelta duration) 90 explicit WaitAndExitDelegate(base::TimeDelta duration)
90 : duration_(duration) {} 91 : duration_(duration) {}
91 92
92 void ThreadMain() override { 93 void ThreadMain() override {
93 base::PlatformThread::Sleep(duration_); 94 base::PlatformThread::Sleep(duration_);
94 _exit(0); 95 _exit(0);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // 132 //
132 // One could make the browser SIGKILL the renderers, but that leaves open a 133 // One could make the browser SIGKILL the renderers, but that leaves open a
133 // large window where a browser failure (or a user, manually terminating 134 // large window where a browser failure (or a user, manually terminating
134 // the browser because "it's stuck") will leave behind a process eating all 135 // the browser because "it's stuck") will leave behind a process eating all
135 // the CPU. 136 // the CPU.
136 // 137 //
137 // So, we install a filter on the sender so that we can process this event 138 // So, we install a filter on the sender so that we can process this event
138 // here and kill the process. 139 // here and kill the process.
139 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 140 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622
140 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ 141 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
141 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) 142 defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
143 defined(UNDEFINED_SANITIZER)) && !defined(OS_CHROMEOS)
142 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection, 144 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection,
143 // or dump code coverage data to disk). Instead of exiting the process 145 // or dump code coverage data to disk). Instead of exiting the process
144 // immediately, we give it 60 seconds to run exit handlers. 146 // immediately, we give it 60 seconds to run exit handlers.
145 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60))); 147 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60)));
146 #if defined(LEAK_SANITIZER) 148 #if defined(LEAK_SANITIZER)
147 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If 149 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If
148 // leaks are found, the process will exit here. 150 // leaks are found, the process will exit here.
149 __lsan_do_leak_check(); 151 __lsan_do_leak_check();
150 #endif 152 #endif
151 #else 153 #else
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 609
608 void ChildThread::OnProcessBackgrounded(bool background) { 610 void ChildThread::OnProcessBackgrounded(bool background) {
609 // Set timer slack to maximum on main thread when in background. 611 // Set timer slack to maximum on main thread when in background.
610 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 612 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
611 if (background) 613 if (background)
612 timer_slack = base::TIMER_SLACK_MAXIMUM; 614 timer_slack = base::TIMER_SLACK_MAXIMUM;
613 base::MessageLoop::current()->SetTimerSlack(timer_slack); 615 base::MessageLoop::current()->SetTimerSlack(timer_slack);
614 } 616 }
615 617
616 } // namespace content 618 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_launcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698