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

Unified Diff: runtime/bin/process_macos.cc

Issue 9225019: Fix race condition between signal handler and main thread. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_macos.cc
diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
index 1d0c5e9d17d6bbb0829fb1a4bf8f3469968a2b5d..57160518a7a63f493c18e880e57025a314835da1 100644
--- a/runtime/bin/process_macos.cc
+++ b/runtime/bin/process_macos.cc
@@ -99,15 +99,21 @@ void ExitHandler(int process_signal, siginfo_t* siginfo, void* tmp) {
exit_code = WTERMSIG(status);
negative = 1;
}
+ // Lookup the process and extract all needed information from
+ // it. The WriteToBlocking call below can cause the deletion of
+ // the process object (because this signal handler can be running
+ // on an arbitrary thread, not just the main thread) so we cannot
+ // touch it after that call.
ProcessInfo* process = LookupProcess(pid);
+ intptr_t exit_code_fd = process->fd();
if (process != NULL) {
int message[3] = { pid, exit_code, negative };
intptr_t result =
- FDUtils::WriteToBlocking(process->fd(), &message, sizeof(message));
+ FDUtils::WriteToBlocking(exit_code_fd, &message, sizeof(message));
if (result != sizeof(message) && errno != EPIPE) {
perror("ExitHandler notification failed");
}
- TEMP_FAILURE_RETRY(close(process->fd()));
+ TEMP_FAILURE_RETRY(close(exit_code_fd));
}
}
errno = entry_errno;
« no previous file with comments | « runtime/bin/process_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698