go/src/cmd/internal
Cherry Zhang b2482e4817 cmd/internal/obj: mark split-stack prologue nonpreemptible
When there are both a synchronous preemption request (by
clobbering the stack guard) and an asynchronous one (by signal),
the running goroutine may observe the synchronous request first
in stack bounds check, and go to the path of calling morestack.
If the preemption signal arrives at this point before the call to
morestack, the goroutine will be asynchronously preempted,
entering the scheduler. When it is resumed, the scheduler clears
the preemption request, unclobbers the stack guard. But the
resumed goroutine will still call morestack, as it is already on
its way. morestack will, as there is no preemption request,
double the stack unnecessarily. If this happens multiple times,
the stack may grow too big, although only a small amount is
actually used.

To fix this, we mark the stack bounds check and the call to
morestack async-nonpreemptible, starting after the memory
instruction (mostly a load, on x86 CMP with memory).

Not done for Wasm as it does not support async preemption.

Fixes #35470.

Change-Id: Ibd7f3d935a3649b80f47539116ec9b9556680cf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/207350
Reviewed-by: David Chase <drchase@google.com>
2019-11-27 01:30:19 +00:00
..
bio cmd/internal/bio: rename Reader.Seek to MustSeek 2019-05-09 16:56:31 +00:00
browser
buildid all: base64-encode binaries that will cause Apple notarization to fail 2019-11-21 14:55:12 +00:00
diff cmd/fix, cmd/go, cmd/gofmt: refactor common code into new internal diff package 2019-10-28 23:59:10 +00:00
dwarf [dev.link] cmd/internal/dwarf: expand import path in function DIE 2019-11-03 04:58:01 +00:00
edit cmd/cover: modify source as text, not as AST 2017-11-13 14:59:26 +00:00
gcprog
goobj [dev.link] cmd/link: assign special indices for builtin functions 2019-10-24 15:24:20 +00:00
goobj2 [dev.link] all: clean up some TODOs 2019-11-01 20:13:05 +00:00
obj cmd/internal/obj: mark split-stack prologue nonpreemptible 2019-11-27 01:30:19 +00:00
objabi cmd/internal/objabi,cmd/link: initial linker support for riscv64 2019-11-13 08:07:51 +00:00
objfile all: remove nacl (part 3, more amd64p32) 2019-10-10 22:38:38 +00:00
src cmd/compile: make a better bogus line for empty infinite loops 2019-11-19 00:38:53 +00:00
sys cmd/go/internal/work: reduce code duplication in buildModeInit by using sys.BuildModeSupported 2019-11-22 21:09:43 +00:00
test2json testing: provide additional information when test funcs panic 2019-10-30 20:46:44 +00:00