Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: fatal error: stack growth after fork #48967

Open
honsunrise opened this issue Oct 14, 2021 · 3 comments · May be fixed by #49001
Open

runtime: fatal error: stack growth after fork #48967

honsunrise opened this issue Oct 14, 2021 · 3 comments · May be fixed by #49001

Comments

@honsunrise
Copy link

@honsunrise honsunrise commented Oct 14, 2021

go/src/runtime/runtime2.go

Lines 211 to 215 in 2feb2cc

func efaceOf(ep *interface{}) *eface {
return (*eface)(unsafe.Pointer(ep))
}

Why this func not have //go:nosplit?

go/src/runtime/proc.go

Lines 446 to 449 in c580180

//go:nosplit
func funcPC(f interface{}) uintptr {
return *(*uintptr)(efaceOf(&f).data)
}

When setsig call funcPC, there will be panic!

fatal error: stack growth after fork

runtime stack:
runtime.throw(0x8afa736, 0x17)
	/usr/local/go/src/runtime/panic.go:1117 +0x6a
runtime.newstack()
	/usr/local/go/src/runtime/stack.go:942 +0xc58
runtime.morestack()
	/usr/local/go/src/runtime/asm_386.s:471 +0x7f

goroutine 50 [running, locked to thread]:
runtime.efaceOf(0xaa23554, 0xa51c72c0)
	/usr/local/go/src/runtime/runtime2.go:213 +0x20 fp=0xaa23548 sp=0xaa23544 pc=0x8091a20
runtime.funcPC(0x89fea00, 0x8b2e9dc, 0x0)
	/usr/local/go/src/runtime/proc.go:448 +0xf fp=0xaa23554 sp=0xaa23548 pc=0x808322f
runtime.setsig(0x1, 0x0)
	/usr/local/go/src/runtime/os_linux.go:427 +0x3a fp=0xaa23578 sp=0xaa23554 pc=0x807d13a
runtime.clearSignalHandlers()
	/usr/local/go/src/runtime/signal_unix.go:259 +0x44 fp=0xaa23588 sp=0xaa23578 pc=0x80950d4
syscall.runtime_AfterForkInChild()
	/usr/local/go/src/runtime/proc.go:3951 +0xf fp=0xaa2359c sp=0xaa23588 pc=0x80ae48f
syscall.forkAndExecInChild1(0xaa26730, 0xaa10168, 0x5, 0x5, 0xaa341c0, 0x1a, 0x1a, 0x0, 0x0, 0xaa23a28, ...)
	/usr/local/go/src/syscall/exec_linux.go:240 +0x6e0 fp=0xaa23794 sp=0xaa2359c pc=0x80c0640
syscall.forkAndExecInChild(0xaa26730, 0xaa10168, 0x5, 0x5, 0xaa341c0, 0x1a, 0x1a, 0x0, 0x0, 0xaa23a28, ...)
	/usr/local/go/src/syscall/exec_linux.go:83 +0xf8 fp=0xaa23830 sp=0xaa23794 pc=0x80bfcd8
syscall.forkExec(0xa89e190, 0x45, 0xaa4a1c0, 0x4, 0x4, 0xaa23a28, 0x0, 0x0, 0x0)
	/usr/local/go/src/syscall/exec_unix.go:211 +0x791 fp=0xaa23930 sp=0xaa23830 pc=0x80c3ad1
syscall.StartProcess(0xa89e190, 0x45, 0xaa4a1c0, 0x4, 0x4, 0xaa23a28, 0x0, 0x0, 0x0, 0x0)
	/usr/local/go/src/syscall/exec_unix.go:263 +0x7d fp=0xaa23964 sp=0xaa23930 pc=0x80c3efd
os.startProcess(0xa89e190, 0x45, 0xaa4a1c0, 0x4, 0x4, 0xaa28600, 0x0, 0x0, 0x0)
	/usr/local/go/src/os/exec_posix.go:53 +0x432 fp=0xaa23a50 sp=0xaa23964 pc=0x815ad42
os.StartProcess(0xa89e190, 0x45, 0xaa4a1c0, 0x4, 0x4, 0xaa28600, 0x0, 0x0, 0x0)
	/usr/local/go/src/os/exec.go:106 +0x91 fp=0xaa23a90 sp=0xaa23a50 pc=0x815a4d1
...
...
@honsunrise honsunrise changed the title may be missing //go:nosplit runtime: fatal error: stack growth after fork Oct 14, 2021
@toothrot toothrot added this to the Backlog milestone Oct 15, 2021
honsunrise pushed a commit to honsunrise/go that referenced this issue Oct 15, 2021
This fix prevents additional stack checking code from being
generated on func efaceOf to avoid unexpected growth of stack
in child process.

Fixes golang#48967

Signed-off-by: Honsun Zhu <honsun@linux.com>
honsunrise pushed a commit to honsunrise/go that referenced this issue Oct 15, 2021
This fix prevents additional stack checking code from being
generated on func efaceOf to avoid unexpected growth of stack
in child process.

Fixes golang#48967
@honsunrise honsunrise linked a pull request that will close this issue Oct 15, 2021
honsunrise added a commit to honsunrise/go that referenced this issue Oct 15, 2021
This fix prevents additional stack checking code from being
generated on func efaceOf to avoid unexpected growth of stack
in child process.

Fixes golang#48967
honsunrise added a commit to honsunrise/go that referenced this issue Oct 15, 2021
This fix prevents additional stack checking code from being
generated on func efaceOf to avoid unexpected growth of stack
in child process.

Fixes golang#48967
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 15, 2021

Change https://golang.org/cl/356109 mentions this issue: runtime: add missing //go:nosplit for efaceOf

Loading

@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Oct 15, 2021

What version of Go are you using? setsig doesn't seem to call through funcPC at present (replaced with the new intrinsics in 1.17: https://cs.opensource.google/go/go/+/master:src/runtime/os_linux.go;l=445;drc=master;bpv=1;bpt=1).

We should maybe backport this though? A stack growth during a vfork or something sounds pretty bad.

Loading

@honsunrise
Copy link
Author

@honsunrise honsunrise commented Oct 16, 2021

I'm using go1.17.2 and have also tested it on 1.16.9.

Yes we should be backport this, the master branche does not need this patch.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants