Repository navigation
Conversation
|
EWS run on previous version of this PR (hash c1aac06) Details
|
c1aac06 to
a743947
Compare
|
EWS run on previous version of this PR (hash a743947) Details
|
… after its pid is reused <https://bugs.webkit.org/show_bug.cgi?id=327960> <rdar://190319872> Reviewed by NOBODY (OOPS!). In ASan builds, `terminateWithReason()` kills the process with `terminate_with_reason()`, which takes a pid. The termination watchdog calls it 30 seconds after the connection was cancelled, so if the child process already exited and its pid was reused, the watchdog kills an unrelated process. `xpc_connection_kill()`, used in other builds, does not have this problem. Call `terminate_with_reason()` only if `proc_pidpath_audittoken()` succeeds for the connection's audit token, which fails once the process that the token identifies has exited, and fall back to `xpc_connection_kill()` otherwise. The iOS Simulator SDKs lack `<libproc.h>`, so those builds skip the check and keep calling `terminate_with_reason()` to preserve their crash reports. No new tests since this change is not directly testable. * Source/WebKit/Platform/cocoa/XPCUtilities.mm: (WebKit::terminateWithReason):
a743947 to
a497ee1
Compare
|
EWS run on current version of this PR (hash a497ee1) Details
|
| if (invalidMessageName) | ||
| code |= static_cast<uint64_t>(std::to_underlying(*invalidMessageName)) << 8; | ||
| if (!terminate_with_reason(xpc_connection_get_pid(connection), OS_REASON_WEBKIT, code, reason, 0)) | ||
| bool isSameProcess = true; |
There was a problem hiding this comment.
Nit: maybe we should move the mutable isSameProcess and its inner #if into a small helper. Non blocking.
| if (!terminate_with_reason(xpc_connection_get_pid(connection), OS_REASON_WEBKIT, code, reason, 0)) | ||
| bool isSameProcess = true; | ||
| #if HAVE(LIBPROC) | ||
| // terminate_with_reason() signals by pid, and the watchdog fires 30s after the connection |
There was a problem hiding this comment.
I don't think the '30s after the connection was cancelled' part of the comment is correct. The timer is armed from terminate(), shutDownProcess() or the destructor, so I think its more accurate to say 'after the watchdog was armed'.
| code |= static_cast<uint64_t>(std::to_underlying(*invalidMessageName)) << 8; | ||
| if (!terminate_with_reason(xpc_connection_get_pid(connection), OS_REASON_WEBKIT, code, reason, 0)) | ||
| bool isSameProcess = true; | ||
| #if HAVE(LIBPROC) |
There was a problem hiding this comment.
Where HAVE(LIBPROC) is false the hazard remains. That includes iOS Simulator, where processes are host processes. We can add a FIXME and mention it in the commit message. Non blocking.
| std::array<char, PROC_PIDPATHINFO_MAXSIZE> path; | ||
| isSameProcess = proc_pidpath_audittoken(&auditToken, path.data(), path.size()) > 0; | ||
| #endif | ||
| if (isSameProcess && !terminate_with_reason(xpc_connection_get_pid(connection), OS_REASON_WEBKIT, code, reason, 0)) |
There was a problem hiding this comment.
Use audit_token_to_pid(auditToken) for the terminate_with_reason pid instead of a second xpc_connection_get_pid. As written, the check can pass while xpc_connection_get_pid returns 0 on a cancelled connection.
zakariaridouh
left a comment
There was a problem hiding this comment.
r+ with some nits and comments
🧪 api-ios
a497ee1
a497ee1