From 9f012e100210b6fb4e9bf8972e3d3b04c44b863a Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Tue, 9 Sep 2014 17:19:01 -0700 Subject: runtime: call rfork on scheduler stack on Plan 9 A race exists between the parent and child processes after a fork. The child needs to access the new M pointer passed as an argument but the parent may have already returned and clobbered it. Previously, we avoided this by saving the necessary data into registers before the rfork system call but this isn't guaranteed to work because Plan 9 makes no promises about the register state after a system call. Only the 386 kernel seems to save them. For amd64 and arm, this method won't work. We eliminate the race by allocating stack space for the scheduler goroutines (g0) in the per-process copy-on-write stack segment and by only calling rfork on the scheduler stack. LGTM=aram, 0intro, rsc R=aram, 0intro, mischief, rsc CC=golang-codereviews https://golang.org/cl/110680044 --- src/runtime/runtime.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/runtime/runtime.h') diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 4622a2c3d7..da9b2b7514 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -522,6 +522,15 @@ enum { Solaris = 0 }; #endif +#ifdef GOOS_plan9 +enum { + Plan9 = 1 +}; +#else +enum { + Plan9 = 0 +}; +#endif // Lock-free stack node. struct LFNode -- cgit v1.3-5-g9baa