]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix stack split detection around fork
authorDmitriy Vyukov <dvyukov@google.com>
Wed, 19 Mar 2014 13:04:51 +0000 (17:04 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Wed, 19 Mar 2014 13:04:51 +0000 (17:04 +0400)
If runtime_BeforeFork splits stack, it will unsplit it
with spoiled g->stackguard. It leads to check failure in oldstack:

fatal error: stackfree: bad fixed size

runtime stack:
runtime.throw(0xadf3cd)
runtime.stackfree(0xc208040480, 0xfffffffffffff9dd, 0x1b00fa8)
runtime.oldstack()
runtime.lessstack()

goroutine 311 [stack unsplit]:
syscall.forkAndExecInChild(0xc20802eea0, 0xc208192c00, 0x5, 0x5, 0xc208072a80, ...)
syscall.forkExec(0xc20802ed80, 0x54, 0xc2081ccb40, 0x4, 0x4, ...)

Fixes #7567.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr, rsc
https://golang.org/cl/77340045

src/pkg/runtime/proc.c

index e11f9b18ac8c6cfd6a471f1be40ba868587a080f..b5093497d9af6048d1638a54256f925fc3eeff42 100644 (file)
@@ -1696,6 +1696,7 @@ exitsyscall0(G *gp)
 }
 
 // Called from syscall package before fork.
+#pragma textflag NOSPLIT
 void
 syscall·runtime_BeforeFork(void)
 {