Close handler_sock after starting crashpad server.

handler_sock end of the socketpair is donated to the crashpad server
process which owns it. The client should not keep it open. Otherwise
if the crashpad server process crashes and the client is reading from
client_sock, the client will hang forever because the other end is still
open.

This happens when:
- /proc/sys/kernel/yama/ptrace_scope file is present.
- crashpad is invoked with missing required fields, like --database.

In this case, chrome hangs until timeout.

Change-Id: I1776432d6d9fd44dc1c24e874a15fd6d2a376003
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3786896
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Ayush Ranjan <ayushranjan@google.com>
This commit is contained in:
Ayush Ranjan 2022-07-25 12:47:53 -07:00 committed by Crashpad LUCI CQ
parent 1b47570f6f
commit bfc0eb5709

View File

@ -462,6 +462,7 @@ bool CrashpadClient::StartHandler(
if (!SpawnSubprocess(argv, nullptr, handler_sock.get(), false, nullptr)) { if (!SpawnSubprocess(argv, nullptr, handler_sock.get(), false, nullptr)) {
return false; return false;
} }
handler_sock.reset();
pid_t handler_pid = -1; pid_t handler_pid = -1;
if (!IsRegularFile(base::FilePath("/proc/sys/kernel/yama/ptrace_scope"))) { if (!IsRegularFile(base::FilePath("/proc/sys/kernel/yama/ptrace_scope"))) {