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

Unified Diff: runtime/bin/process_linux.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/file_impl.dart ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_linux.cc
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
index 64d8545a24c2564229352362bc71642668509bf5..61fec206af54f687da37148bdf32f43402ec195b 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -100,15 +100,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/file_impl.dart ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698