From 6b59d618226259801fea6eb820587a449690261a Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Wed, 9 Mar 2016 16:16:05 +0000 Subject: [PATCH] runtime: Plan 9 - prevent preemption by GC while exiting On Plan 9, there's no "kill all threads" system call, so exit is done by sending a "go: exit" note to each OS process. If concurrent GC occurs during this loop, deadlock sometimes results. Prevent this by incrementing m.locks before sending notes. Change-Id: I31aa15134ff6e42d9a82f9f8a308620b3ad1b1b1 Reviewed-on: https://go-review.googlesource.com/20477 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/runtime/os1_plan9.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/runtime/os1_plan9.go b/src/runtime/os1_plan9.go index c114b1db62..b0b05bb7d7 100644 --- a/src/runtime/os1_plan9.go +++ b/src/runtime/os1_plan9.go @@ -151,6 +151,7 @@ var goexits = []byte("go: exit ") func goexitsall(status *byte) { var buf [_ERRMAX]byte + getg().m.locks++ n := copy(buf[:], goexits) n = copy(buf[n:], gostringnocopy(status)) pid := getpid() @@ -159,6 +160,7 @@ func goexitsall(status *byte) { postnote(mp.procid, buf[:]) } } + getg().m.locks-- } var procdir = []byte("/proc/") -- 2.48.1