diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2011-11-09 23:11:48 +0300 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2011-11-09 23:11:48 +0300 |
| commit | fbfed49134bca038184dbc1a427e82647fc1f12e (patch) | |
| tree | 63a64a5b3c1ff5b483371cab31d2807b7ad79e40 /src/pkg/runtime/amd64 | |
| parent | 98321731f2e09d71ea153e8c6ae8abdf6fa881bd (diff) | |
| download | go-fbfed49134bca038184dbc1a427e82647fc1f12e.tar.xz | |
cgo: fix g0 stack guard
Fixes crash when cgo consumes more than 8K
of stack and makes a callback.
Fixes #1328.
R=golang-dev, rogpeppe, rsc
CC=golang-dev, mpimenov
https://golang.org/cl/5371042
Diffstat (limited to 'src/pkg/runtime/amd64')
| -rw-r--r-- | src/pkg/runtime/amd64/asm.s | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/runtime/amd64/asm.s b/src/pkg/runtime/amd64/asm.s index 866e083106..109b95eba8 100644 --- a/src/pkg/runtime/amd64/asm.s +++ b/src/pkg/runtime/amd64/asm.s @@ -17,6 +17,7 @@ TEXT _rt0_amd64(SB),7,$-8 MOVQ initcgo(SB), AX TESTQ AX, AX JZ needtls + LEAQ runtime·g0(SB), DI CALL AX CMPL runtime·iswindows(SB), $0 JEQ ok @@ -44,8 +45,13 @@ ok: MOVQ CX, m_g0(AX) // create istack out of the given (operating system) stack + // if there is an initcgo, it had setup stackguard for us + MOVQ initcgo(SB), AX + TESTQ AX, AX + JNZ stackok LEAQ (-8192+104)(SP), AX MOVQ AX, g_stackguard(CX) +stackok: MOVQ SP, g_stackbase(CX) CLD // convention is D is always left cleared |
