mac: Deal with bootstrap_look_up() race encountered on 10.12.1

bootstrap_look_up() “successfully” returns MACH_PORT_DEAD about half of
the time on 10.12.1 16B2657 (xnu-3789.21.4). Replace that with
MACH_PORT_NULL in the BootstrapLookUp() wrapper that all callers are
already routed through.

BUG=crashpad:139
TEST=crashpad_util_test MachExtensions.BootstrapCheckInAndLookUp

Change-Id: I9a39b709add5ca7e64bb5b970ed6ba3fdfd1d47a
Reviewed-on: https://chromium-review.googlesource.com/409671
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Mark Mentovai 2016-11-09 16:52:40 -05:00
parent 3abde199a7
commit 741c9cc51e

View File

@ -157,7 +157,26 @@ base::mac::ScopedMachReceiveRight BootstrapCheckIn(
base::mac::ScopedMachSendRight BootstrapLookUp( base::mac::ScopedMachSendRight BootstrapLookUp(
const std::string& service_name) { const std::string& service_name) {
return BootstrapCheckInOrLookUp<BootstrapLookUpTraits>(service_name); base::mac::ScopedMachSendRight send(
BootstrapCheckInOrLookUp<BootstrapLookUpTraits>(service_name));
// Its possible to race the bootstrap server when the receive right
// corresponding to the looked-up send right is destroyed immediately before
// the bootstrap_look_up() call. If the bootstrap server believes that
// |service_name| is still registered before processing the port-destroyed
// notification sent to it by the kernel, it will respond to a
// bootstrap_look_up() request with a send right that has become a dead name,
// which will be returned to the bootstrap_look_up() caller, translated into
// the callers IPC port name space, as the special MACH_PORT_DEAD port name.
// Check for that and return MACH_PORT_NULL in its place, as though the
// bootstrap server had fully processed the port-destroyed notification before
// responding to bootstrap_look_up().
if (send.get() == MACH_PORT_DEAD) {
LOG(ERROR) << "bootstrap_look_up " << service_name << ": service is dead";
send.reset();
}
return send;
} }
base::mac::ScopedMachSendRight SystemCrashReporterHandler() { base::mac::ScopedMachSendRight SystemCrashReporterHandler() {