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

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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
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/browser/zygote_host/zygote_host_impl_linux.h" 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
6 6
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 sandbox_host->PrependWrapper(cmd_line); 155 sandbox_host->PrependWrapper(cmd_line);
156 sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd); 156 sandbox_host->SetupLaunchOptions(&options, &fds_to_map, &dummy_fd);
157 sandbox_host->SetupLaunchEnvironment(); 157 sandbox_host->SetupLaunchEnvironment();
158 } 158 }
159 159
160 options.fds_to_remap = &fds_to_map; 160 options.fds_to_remap = &fds_to_map;
161 base::Process process = 161 base::Process process =
162 use_namespace_sandbox_ 162 use_namespace_sandbox_
163 ? sandbox::NamespaceSandbox::LaunchProcess(*cmd_line, options) 163 ? sandbox::NamespaceSandbox::LaunchProcess(*cmd_line, options)
164 : base::LaunchProcess(*cmd_line, options); 164 : base::LaunchProcess(*cmd_line, options);
165 CHECK(process.IsValid()) << "Failed to launch zygote process"; 165 // Failed to launch zygote process
166 CHECK(process.IsValid());
166 167
167 dummy_fd.reset(); 168 dummy_fd.reset();
168 close(fds[1]); 169 close(fds[1]);
169 control_fd->reset(fds[0]); 170 control_fd->reset(fds[0]);
170 171
171 pid_t pid = process.Pid(); 172 pid_t pid = process.Pid();
172 173
173 if (use_namespace_sandbox_ || use_suid_sandbox_) { 174 if (use_namespace_sandbox_ || use_suid_sandbox_) {
174 // The namespace and SUID sandbox will execute the zygote in a new 175 // The namespace and SUID sandbox will execute the zygote in a new
175 // PID namespace, and the main zygote process will then fork from 176 // PID namespace, and the main zygote process will then fork from
176 // there. Watch now our elaborate dance to find and validate the 177 // there. Watch now our elaborate dance to find and validate the
177 // zygote's PID. 178 // zygote's PID.
178 179
179 // First we receive a message from the zygote boot process. 180 // First we receive a message from the zygote boot process.
180 base::ProcessId boot_pid; 181 base::ProcessId boot_pid;
181 CHECK(ReceiveFixedMessage(fds[0], kZygoteBootMessage, 182 CHECK(ReceiveFixedMessage(fds[0], kZygoteBootMessage,
182 sizeof(kZygoteBootMessage), &boot_pid)); 183 sizeof(kZygoteBootMessage), &boot_pid));
183 184
184 // Within the PID namespace, the zygote boot process thinks it's PID 1, 185 // Within the PID namespace, the zygote boot process thinks it's PID 1,
185 // but its real PID can never be 1. This gives us a reliable test that 186 // but its real PID can never be 1. This gives us a reliable test that
186 // the kernel is translating the sender's PID to our namespace. 187 // the kernel is translating the sender's PID to our namespace.
187 CHECK_GT(boot_pid, 1) 188 // If this fails, the kernel might be too old? See crbug.com/357670 or try
188 << "Received invalid process ID for zygote; kernel might be too old? " 189 // using --no-sandbox to workaround.
189 "See crbug.com/357670 or try using --" 190 CHECK_GT(boot_pid, 1);
190 << switches::kNoSandbox << " to workaround.";
191 191
192 // Now receive the message that the zygote's ready to go, along with the 192 // Now receive the message that the zygote's ready to go, along with the
193 // main zygote process's ID. 193 // main zygote process's ID.
194 pid_t real_pid; 194 pid_t real_pid;
195 CHECK(ReceiveFixedMessage(fds[0], kZygoteHelloMessage, 195 CHECK(ReceiveFixedMessage(fds[0], kZygoteHelloMessage,
196 sizeof(kZygoteHelloMessage), &real_pid)); 196 sizeof(kZygoteHelloMessage), &real_pid));
197 CHECK_GT(real_pid, 1); 197 CHECK_GT(real_pid, 1);
198 198
199 if (real_pid != pid) { 199 if (real_pid != pid) {
200 // Reap the sandbox. 200 // Reap the sandbox.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (sandbox_helper_process.IsValid()) 273 if (sandbox_helper_process.IsValid())
274 base::EnsureProcessGetsReaped(sandbox_helper_process.Pid()); 274 base::EnsureProcessGetsReaped(sandbox_helper_process.Pid());
275 } else if (!use_suid_sandbox_for_adj_oom_score_) { 275 } else if (!use_suid_sandbox_for_adj_oom_score_) {
276 if (!base::AdjustOOMScore(pid, score)) 276 if (!base::AdjustOOMScore(pid, score))
277 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid; 277 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid;
278 } 278 }
279 } 279 }
280 #endif 280 #endif
281 281
282 } // namespace content 282 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698