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: Goexit doesn't crash the program #42505

Open
fxrlv opened this issue Nov 11, 2020 · 2 comments
Open

runtime: Goexit doesn't crash the program #42505

fxrlv opened this issue Nov 11, 2020 · 2 comments

Comments

@fxrlv
Copy link

@fxrlv fxrlv commented Nov 11, 2020

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

$ go version
go version go1.15.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/fxrlv/Library/Caches/go-build"
GOENV="/Users/fxrlv/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/fxrlv/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/fxrlv/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3r/9dz2gvss1cq9j8y7_76cgs300000gn/T/go-build700045611=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

case 1

package main

import (
	"runtime"
)

func main() {
	runtime.Goexit()
}

case 2

package main

import (
	_ "net/http"
	"runtime"
)

func main() {
	runtime.Goexit()
}

What did you expect to see?

two cases produce the same, should crash

What did you see instead?

second case hangs forever

@bcmills
Copy link
Member

@bcmills bcmills commented Nov 11, 2020

Running the second program with GOTRACEBACK=system and terminating it with SIGQUIT gives:

SIGQUIT: quit
PC=0x46cb01 m=0 sigcode=128

goroutine 0 [idle]:
runtime.futex(0x681130, 0x80, 0x0, 0x0, 0x0, 0x46ace1, 0x1fdb9, 0x0, 0x7ffee1b5d1e8, 0x40d51f, ...)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/sys_linux_amd64.s:579 +0x21 fp=0x7ffee1b5d170 sp=0x7ffee1b5d168 pc=0x46cb01
runtime.futexsleep(0x681130, 0x0, 0xffffffffffffffff)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/os_linux.go:44 +0x46 fp=0x7ffee1b5d1c0 sp=0x7ffee1b5d170 pc=0x432b86
runtime.notesleep(0x681130)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/lock_futex.go:159 +0x9f fp=0x7ffee1b5d1f8 sp=0x7ffee1b5d1c0 pc=0x40d51f
runtime.mPark()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:1273 +0x39 fp=0x7ffee1b5d218 sp=0x7ffee1b5d1f8 pc=0x43c279
runtime.stopm()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:2185 +0x92 fp=0x7ffee1b5d240 sp=0x7ffee1b5d218 pc=0x43d8d2
runtime.findrunnable(0xc00002c000, 0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:2844 +0x72e fp=0x7ffee1b5d368 sp=0x7ffee1b5d240 pc=0x43ee0e
runtime.schedule()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:3051 +0x2d7 fp=0x7ffee1b5d3d0 sp=0x7ffee1b5d368 pc=0x440157
runtime.goexit0(0xc000000180)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:3360 +0x1de fp=0x7ffee1b5d410 sp=0x7ffee1b5d3d0 pc=0x44115e
runtime.mcall(0x0)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/asm_amd64.s:323 +0x5b fp=0x7ffee1b5d420 sp=0x7ffee1b5d410 pc=0x468e7b

goroutine 2 [force gc (idle)]:
runtime.gopark(0x581b68, 0x6806b0, 0x1411, 0x1)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:336 +0xe5 fp=0xc000044fb0 sp=0xc000044f90 pc=0x439a05
runtime.goparkunlock(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:342
runtime.forcegchelper()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:276 +0xc5 fp=0xc000044fe0 sp=0xc000044fb0 pc=0x439865
runtime.goexit()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/asm_amd64.s:1367 +0x1 fp=0xc000044fe8 sp=0xc000044fe0 pc=0x46ace1
created by runtime.init.6
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:264 +0x35

goroutine 3 [GC sweep wait]:
runtime.gopark(0x581b68, 0x680860, 0x140c, 0x1)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:336 +0xe5 fp=0xc0000457a8 sp=0xc000045788 pc=0x439a05
runtime.goparkunlock(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:342
runtime.bgsweep(0xc000018150)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mgcsweep.go:163 +0x9e fp=0xc0000457d8 sp=0xc0000457a8 pc=0x42547e
runtime.goexit()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/asm_amd64.s:1367 +0x1 fp=0xc0000457e0 sp=0xc0000457d8 pc=0x46ace1
created by runtime.gcenable
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mgc.go:217 +0x5c

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x581b68, 0x680a00, 0x140d, 0x1)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:336 +0xe5 fp=0xc000045f78 sp=0xc000045f58 pc=0x439a05
runtime.goparkunlock(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:342
runtime.bgscavenge(0xc000018150)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mgcscavenge.go:265 +0xd2 fp=0xc000045fd8 sp=0xc000045f78 pc=0x4234d2
runtime.goexit()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/asm_amd64.s:1367 +0x1 fp=0xc000045fe0 sp=0xc000045fd8 pc=0x46ace1
created by runtime.gcenable
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mgc.go:218 +0x7e

goroutine 5 [finalizer wait]:
runtime.gopark(0x581b68, 0x6ae820, 0xffff1410, 0x1)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:336 +0xe5 fp=0xc000044758 sp=0xc000044738 pc=0x439a05
runtime.goparkunlock(...)
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/proc.go:342
runtime.runfinq()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mfinal.go:175 +0xa9 fp=0xc0000447e0 sp=0xc000044758 pc=0x41a829
runtime.goexit()
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/asm_amd64.s:1367 +0x1 fp=0xc0000447e8 sp=0xc0000447e0 pc=0x46ace1
created by runtime.createfing
        /usr/local/google/home/bcmills/sdk/gotip/src/runtime/mfinal.go:156 +0x65

rax    0xca
rbx    0x680fe0
rcx    0x46cb03
rdx    0x0
rdi    0x681130
rsi    0x80
rbp    0x7ffee1b5d1b0
rsp    0x7ffee1b5d168
r8     0x0
r9     0x0
r10    0x0
r11    0x286
r12    0x0
r13    0x680e60
r14    0x0
r15    0x0
rip    0x46cb01
rflags 0x286
cs     0x33
fs     0x0
gs     0x0
exit status 2

As far as I can tell that's nothing but system goroutines, so this does seem like a bug.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Nov 11, 2020

This doesn't seem like a serious bug. Without the import of net/http, the program crashes with no goroutines (main called runtime.Goexit) - deadlock!. With the import of net/http, the program doesn't crash because it is a cgo program. See #25538. That issue was closed, but this one could be fixed in principle because the use of cgo is only implicit.

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.

None yet
3 participants
You can’t perform that action at this time.