OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 return kExcMaskValid_10_11; | 150 return kExcMaskValid_10_11; |
151 } | 151 } |
152 | 152 |
153 base::mac::ScopedMachReceiveRight BootstrapCheckIn( | 153 base::mac::ScopedMachReceiveRight BootstrapCheckIn( |
154 const std::string& service_name) { | 154 const std::string& service_name) { |
155 return BootstrapCheckInOrLookUp<BootstrapCheckInTraits>(service_name); | 155 return BootstrapCheckInOrLookUp<BootstrapCheckInTraits>(service_name); |
156 } | 156 } |
157 | 157 |
158 base::mac::ScopedMachSendRight BootstrapLookUp( | 158 base::mac::ScopedMachSendRight BootstrapLookUp( |
159 const std::string& service_name) { | 159 const std::string& service_name) { |
160 return BootstrapCheckInOrLookUp<BootstrapLookUpTraits>(service_name); | 160 base::mac::ScopedMachSendRight send( |
| 161 BootstrapCheckInOrLookUp<BootstrapLookUpTraits>(service_name)); |
| 162 |
| 163 // It’s possible to race the bootstrap server when the receive right |
| 164 // corresponding to the looked-up send right is destroyed immediately before |
| 165 // the bootstrap_look_up() call. If the bootstrap server believes that |
| 166 // |service_name| is still registered before processing the port-destroyed |
| 167 // notification sent to it by the kernel, it will respond to a |
| 168 // bootstrap_look_up() request with a send right that has become a dead name, |
| 169 // which will be returned to the bootstrap_look_up() caller, translated into |
| 170 // the caller’s IPC port name space, as the special MACH_PORT_DEAD port name. |
| 171 // Check for that and return MACH_PORT_NULL in its place, as though the |
| 172 // bootstrap server had fully processed the port-destroyed notification before |
| 173 // responding to bootstrap_look_up(). |
| 174 if (send.get() == MACH_PORT_DEAD) { |
| 175 LOG(ERROR) << "bootstrap_look_up " << service_name << ": service is dead"; |
| 176 send.reset(); |
| 177 } |
| 178 |
| 179 return send; |
161 } | 180 } |
162 | 181 |
163 base::mac::ScopedMachSendRight SystemCrashReporterHandler() { | 182 base::mac::ScopedMachSendRight SystemCrashReporterHandler() { |
164 return BootstrapLookUp("com.apple.ReportCrash"); | 183 return BootstrapLookUp("com.apple.ReportCrash"); |
165 } | 184 } |
166 | 185 |
167 } // namespace crashpad | 186 } // namespace crashpad |
OLD | NEW |