diff options
| author | Russ Cox <rsc@golang.org> | 2013-07-12 12:12:56 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-07-12 12:12:56 -0400 |
| commit | 031c107cad93174a6e33d3af31c1e3613129ad08 (patch) | |
| tree | a2388a8082804254a26495e0a831a20344d03098 /src/pkg/runtime/stack.h | |
| parent | 56cd47b295e033f39534d80effc45f4abe125bec (diff) | |
| download | go-031c107cad93174a6e33d3af31c1e3613129ad08.tar.xz | |
cmd/ld: fix large stack split for preempt check
If the stack frame size is larger than the known-unmapped region at the
bottom of the address space, then the stack split prologue cannot use the usual
condition:
SP - size >= stackguard
because SP - size may wrap around to a very large number.
Instead, if the stack frame is large, the prologue tests:
SP - stackguard >= size
(This ends up being a few instructions more expensive, so we don't do it always.)
Preemption requests register by setting stackguard to a very large value, so
that the first test (SP - size >= stackguard) cannot possibly succeed.
Unfortunately, that same very large value causes a wraparound in the
second test (SP - stackguard >= size), making it succeed incorrectly.
To avoid *that* wraparound, we have to amend the test:
stackguard != StackPreempt && SP - stackguard >= size
This test is only used for functions with large frames, which essentially
always split the stack, so the cost of the few instructions is noise.
This CL and CL 11085043 together fix the known issues with preemption,
at the beginning of a function, so we will be able to try turning it on again.
R=ken2
CC=golang-dev
https://golang.org/cl/11205043
Diffstat (limited to 'src/pkg/runtime/stack.h')
| -rw-r--r-- | src/pkg/runtime/stack.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pkg/runtime/stack.h b/src/pkg/runtime/stack.h index f56d4a7263..2784a8620f 100644 --- a/src/pkg/runtime/stack.h +++ b/src/pkg/runtime/stack.h @@ -109,4 +109,4 @@ enum { // Stored into g->stackguard0 to cause split stack check failure. // Must be greater than any real sp. // 0xfffffade in hex. -#define StackPreempt ((uintptr)-1314) +#define StackPreempt ((uint64)-1314) |
