]> Cypherpunks repositories - gostls13.git/commit
syscall: avoid race in plan9 while syncing Chdir across goroutines
authormiller <millerresearch@gmail.com>
Tue, 7 Mar 2023 15:15:10 +0000 (15:15 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 9 Mar 2023 00:51:36 +0000 (00:51 +0000)
commitfc45eb388d3693e35b1aa97cb553d2a5083c8b2f
tree75208ff52e2fb587404a5ea1056986a305a19a91
parentd6fa0d2ef3fc29c38af2675d395a089cc73af996
syscall: avoid race in plan9 while syncing Chdir across goroutines

Because each M in Plan 9 runs in a separate OS process with its
own current working directory, a Chdir call in one goroutine needs
to be propagated to other goroutines before a subsequent syscall
with a local pathname (see #9428). This is done by function
syscall.Fixwd, but there is still a race if a goroutine is
preempted and rescheduled on a different M between calling Fixwd
and executing the syscall which it protects. By locking the
goroutine to its OS thread from the start of Fixwd to the end of
the protected syscall, this race can be prevented.

Fixes #58802.

Change-Id: I89c0e43ef4544b5bfb5db7d2158f13f24b42e1f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/474055
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/syscall/pwd_plan9.go
src/syscall/syscall_plan9.go