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: accidental stack growth in runtime.sigfillset after forking #43066

Closed
aegistudio opened this issue Dec 8, 2020 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@aegistudio
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version go1.13.15 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

$ go env
go env
GO111MODULE=""
GOARCH="386"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPRIVATE=""
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
GO386="sse2"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-m32 -fPIC -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build592775797=/tmp/go-build -gno-record-gcc-switches"

(Environments like GOPATH, GOPROXY and go-proxy related variables contains sensitive data and is stripped, I think it will not affect the outcome)

Please notice that the build is performed in a docker container, which produces a (statically linked) elf-i686 binary to execute on i686 machine. The information for that machine is provided as below.

$ uname -a
Linux ubuntu 4.4.0-142-generic #168-Ubuntu SMP Wed Jan 16 21:01:15 UTC 2019 i686 i686 i686 GNU/Linux
root@ubuntu:/tmp# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.6 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.6 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

What did you do?

I've attempted to fork and execute another process using os.StartProcess on i686 machine.

What did you expect to see?

The os.StartProcess forks and executes the specified subprocess.

What did you see instead?

The forked process panics soon with a message rendered as below:

fatal error: stack growth after fork

runtime stack:
runtime.throw(0x88f17a9, 0x17)
/usr/local/go/src/runtime/panic.go:774 +0x6a
runtime.newstack()
/usr/local/go/src/runtime/stack.go:921 +0xbe3
runtime.morestack()
/usr/local/go/src/runtime/asm_386.s:479 +0x7f

goroutine 32 [running, locked to thread]:
runtime.sigfillset(0x9848580)
/usr/local/go/src/runtime/os_linux_generic.go:41 +0x29 fp=0x9848568 sp=0x9848564 pc=0x80748b9
runtime.setsig(0x1, 0x0)
/usr/local/go/src/runtime/os_linux.go:380 +0x22 fp=0x984858c sp=0x9848568 pc=0x8074602
runtime.clearSignalHandlers()
/usr/local/go/src/runtime/signal_unix.go:227 +0x44 fp=0x984859c sp=0x984858c pc=0x808a5b4
syscall.runtime_AfterForkInChild()
/usr/local/go/src/runtime/proc.go:3214 +0xf fp=0x98485b0 sp=0x984859c pc=0x807ecdf
syscall.forkAndExecInChild1(0x982a320, 0x986d6b0, 0x9, 0x9, 0x986d6e0, 0xc, 0xc, 0x0, 0x0, 0x9848a18, ...)
/usr/local/go/src/syscall/exec_linux.go:225 +0x6e9 fp=0x98487b0 sp=0x98485b0 pc=0x80cbf09
syscall.forkAndExecInChild(0x982a320, 0x986d6b0, 0x9, 0x9, 0x986d6e0, 0xc, 0xc, 0x0, 0x0, 0x9848a18, ...)
/usr/local/go/src/syscall/exec_linux.go:72 +0xbe fp=0x9848838 sp=0x98487b0 pc=0x80cb5ae
syscall.forkExec(0x982a230, 0x46, 0x9863d40, 0x8, 0x8, 0x9848a18, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/exec_unix.go:201 +0x623 fp=0x9848924 sp=0x9848838 pc=0x80cf1c3
syscall.StartProcess(0x982a230, 0x46, 0x9863d40, 0x8, 0x8, 0x9848a18, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/syscall/exec_unix.go:248 +0x7d fp=0x9848958 sp=0x9848924 pc=0x80cf57d
os.startProcess(0x982a230, 0x46, 0x9863d40, 0x8, 0x8, 0x986d680, 0x0, 0x0, 0x0)
/usr/local/go/src/os/exec_posix.go:52 +0x436 fp=0x9848a40 sp=0x9848958 pc=0x8142dc6
os.StartProcess(0x982a230, 0x46, 0x9863d40, 0x8, 0x8, 0x986d680, 0x0, 0x0, 0x0)
/usr/local/go/src/os/exec.go:102 +0x91 fp=0x9848a80 sp=0x9848a40 pc=0x8142551
... // caller omitted

The parent process soon receives an error of forked process exited with code 2 in this case.

@gopherbot
Copy link

Change https://golang.org/cl/276173 mentions this issue: runtime: prevent stack growth after fork in runtime.sigfillset

@aclements aclements added this to the Go1.16 milestone Dec 8, 2020
@aclements aclements added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 8, 2020
@ALTree ALTree changed the title runtime: accidental stack growth in runtime.sigfillset after forking. runtime: accidental stack growth in runtime.sigfillset after forking Dec 8, 2020
@golang golang locked and limited conversation to collaborators Dec 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants