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

cmd/compile: when cmd/compile is compiled with -gcflags = "all=-N -l", the output binary panic on start #54412

Closed
jacobishao opened this issue Aug 12, 2022 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge

Comments

@jacobishao
Copy link
Contributor

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

$ go version
go version devel go1.20-8cb350d69a Fri Aug 12 03:22:59 2022 +0000 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="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/bytedance/Library/Caches/go-build"
GOENV="/Users/bytedance/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/bytedance/go/pkg/mod"
GONOPROXY="code.byted.org,gitlab.everphoto.cn,git.byted.org,sysrepo.byted.org"
GONOSUMDB="*.byted.org,*.everphoto.cn"
GOOS="darwin"
GOPATH="/Users/bytedance/go"
GOPRIVATE="*.byted.org,*.everphoto.cn"
GOPROXY="https://go-mod-proxy.byted.org,https://proxy.golang.org,direct"
GOROOT="/Users/bytedance/project/go"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/Users/bytedance/project/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.20-8cb350d69a Fri Aug 12 03:22:59 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/bytedance/project/go/src/cmd/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h2/sq_m4g4n047bclxgllsnkbfr0000gn/T/go-build685775542=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cd ${your go sdk root}/src/cmd/compile
go build -o main -gcflags "all=-N -l" main.go
./main

What did you expect to see?

see the help content of compile command

What did you see instead?

runtime: newstack at runtime/internal/atomic.(*Bool).Load+0x34 sp=0xc00010d700 stack=[0xc00010c000, 0xc00010e000]
morebuf={pc:0x1046d11 sp:0xc00010d708 lr:0x0}
sched={pc:0x1002354 sp:0xc00010d700 lr:0x0 ctxt:0x0}
runtime.reentersyscall(0x106e7bf, 0xc00010d768)
/Users/bytedance/project/go/src/runtime/proc.go:3696 +0xf1 fp=0xc00010d748 sp=0xc00010d708 pc=0x1046d11
runtime.entersyscall()
/Users/bytedance/project/go/src/runtime/proc.go:3729 +0x1d fp=0xc00010d768 sp=0xc00010d748 pc=0x106d15d
syscall.syscall(0x107b454?, 0x1ce59c0?, 0x1eac4f0?, 0xc0000221e0?)
/Users/bytedance/project/go/src/runtime/sys_darwin.go:22 +0x7f fp=0xc00010d7f8 sp=0xc00010d768 pc=0x106e7bf
syscall.fcntl(0x0, 0x3, 0x0)
/Users/bytedance/project/go/src/syscall/zsyscall_darwin_amd64.go:319 +0x5c fp=0xc00010d868 sp=0xc00010d7f8 pc=0x10d929c
internal/syscall/unix.IsNonblock(0x0)
/Users/bytedance/project/go/src/internal/syscall/unix/nonblocking_libc.go:15 +0x3f fp=0xc00010d8d8 sp=0xc00010d868 pc=0x11032bf
os.NewFile(0x0, {0x1d798c0, 0xa})
/Users/bytedance/project/go/src/os/file_unix.go:103 +0x4c fp=0xc00010d948 sp=0xc00010d8d8 pc=0x1118f0c
os.init()
/Users/bytedance/project/go/src/os/file.go:65 +0x1e8 fp=0xc00010d990 sp=0xc00010d948 pc=0x111ce68
runtime.doInit(0x2269c80)
/Users/bytedance/project/go/src/runtime/proc.go:6413 +0x132 fp=0xc00010dac0 sp=0xc00010d990 pc=0x104d2b2
runtime.doInit(0x22679e0)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010dbf0 sp=0xc00010dac0 pc=0x104d1f9
runtime.doInit(0x226bf60)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010dd20 sp=0xc00010dbf0 pc=0x104d1f9
runtime.doInit(0x2268b80)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010de50 sp=0xc00010dd20 pc=0x104d1f9
runtime.doInit(0x226a2c0)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010df80 sp=0xc00010de50 pc=0x104d1f9
runtime.main()
/Users/bytedance/project/go/src/runtime/proc.go:233 +0x194 fp=0xc00010dfe0 sp=0xc00010df80 pc=0x103fab4
runtime.goexit()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00010dfe8 sp=0xc00010dfe0 pc=0x1071de1
fatal error: runtime: stack split at bad time

runtime stack:
runtime.throw({0x1d90620?, 0x226e360?})
/Users/bytedance/project/go/src/runtime/panic.go:1047 +0x5d fp=0x7ffeefbff6d0 sp=0x7ffeefbff6a0 pc=0x103d33d
runtime.newstack()
/Users/bytedance/project/go/src/runtime/stack.go:995 +0xaa5 fp=0x7ffeefbff878 sp=0x7ffeefbff6d0 pc=0x1058425
runtime.morestack()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:570 +0x8b fp=0x7ffeefbff880 sp=0x7ffeefbff878 pc=0x106fe2b

goroutine 1 [syscall, locked to thread]:
runtime.reentersyscall(0x106e7bf, 0xc00010d768)
/Users/bytedance/project/go/src/runtime/proc.go:3696 +0xf1 fp=0xc00010d748 sp=0xc00010d708 pc=0x1046d11
runtime.entersyscall()
/Users/bytedance/project/go/src/runtime/proc.go:3729 +0x1d fp=0xc00010d768 sp=0xc00010d748 pc=0x106d15d
syscall.syscall(0x107b454?, 0x1ce59c0?, 0x1eac4f0?, 0xc0000221e0?)
/Users/bytedance/project/go/src/runtime/sys_darwin.go:22 +0x7f fp=0xc00010d7f8 sp=0xc00010d768 pc=0x106e7bf
syscall.fcntl(0x0, 0x3, 0x0)
/Users/bytedance/project/go/src/syscall/zsyscall_darwin_amd64.go:319 +0x5c fp=0xc00010d868 sp=0xc00010d7f8 pc=0x10d929c
internal/syscall/unix.IsNonblock(0x0)
/Users/bytedance/project/go/src/internal/syscall/unix/nonblocking_libc.go:15 +0x3f fp=0xc00010d8d8 sp=0xc00010d868 pc=0x11032bf
os.NewFile(0x0, {0x1d798c0, 0xa})
/Users/bytedance/project/go/src/os/file_unix.go:103 +0x4c fp=0xc00010d948 sp=0xc00010d8d8 pc=0x1118f0c
os.init()
/Users/bytedance/project/go/src/os/file.go:65 +0x1e8 fp=0xc00010d990 sp=0xc00010d948 pc=0x111ce68
runtime.doInit(0x2269c80)
/Users/bytedance/project/go/src/runtime/proc.go:6413 +0x132 fp=0xc00010dac0 sp=0xc00010d990 pc=0x104d2b2
runtime.doInit(0x22679e0)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010dbf0 sp=0xc00010dac0 pc=0x104d1f9
runtime.doInit(0x226bf60)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010dd20 sp=0xc00010dbf0 pc=0x104d1f9
runtime.doInit(0x2268b80)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010de50 sp=0xc00010dd20 pc=0x104d1f9
runtime.doInit(0x226a2c0)
/Users/bytedance/project/go/src/runtime/proc.go:6390 +0x79 fp=0xc00010df80 sp=0xc00010de50 pc=0x104d1f9
runtime.main()
/Users/bytedance/project/go/src/runtime/proc.go:233 +0x194 fp=0xc00010dfe0 sp=0xc00010df80 pc=0x103fab4
runtime.goexit()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00010dfe8 sp=0xc00010dfe0 pc=0x1071de1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x1daa9b8, 0x2317530, 0x11, 0x14, 0x1)
/Users/bytedance/project/go/src/runtime/proc.go:363 +0xfd fp=0xc000058f88 sp=0xc000058f58 pc=0x103ff3d
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
/Users/bytedance/project/go/src/runtime/proc.go:369 +0x2a fp=0xc000058fb8 sp=0xc000058f88 pc=0x103ffca
runtime.forcegchelper()
/Users/bytedance/project/go/src/runtime/proc.go:302 +0xa5 fp=0xc000058fe0 sp=0xc000058fb8 pc=0x103fd65
runtime.goexit()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000058fe8 sp=0xc000058fe0 pc=0x1071de1
created by runtime.init.5
/Users/bytedance/project/go/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x1daa9b8, 0x2317920, 0xc, 0x14, 0x1)
/Users/bytedance/project/go/src/runtime/proc.go:363 +0xfd fp=0xc000059768 sp=0xc000059738 pc=0x103ff3d
runtime.goparkunlock(0x0?, 0x0?, 0x0?, 0x0?)
/Users/bytedance/project/go/src/runtime/proc.go:369 +0x2a fp=0xc000059798 sp=0xc000059768 pc=0x103ffca
runtime.bgsweep(0x0?)
/Users/bytedance/project/go/src/runtime/mgcsweep.go:279 +0x98 fp=0xc0000597c8 sp=0xc000059798 pc=0x1028918
runtime.gcenable.func1()
/Users/bytedance/project/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000597e0 sp=0xc0000597c8 pc=0x101c886
runtime.goexit()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0000597e8 sp=0xc0000597e0 pc=0x1071de1
created by runtime.gcenable
/Users/bytedance/project/go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1daa9b8, 0x2317ec0, 0xd, 0x14, 0x2)
/Users/bytedance/project/go/src/runtime/proc.go:363 +0xfd fp=0xc000059f48 sp=0xc000059f18 pc=0x103ff3d
runtime.goparkunlock(0x1eac398?, 0x1?, 0x0?, 0x0?)
/Users/bytedance/project/go/src/runtime/proc.go:369 +0x2a fp=0xc000059f78 sp=0xc000059f48 pc=0x103ffca
runtime.(*scavengerState).park(0x2317ec0)
/Users/bytedance/project/go/src/runtime/mgcscavenge.go:389 +0x4b fp=0xc000059fa0 sp=0xc000059f78 pc=0x102658b
runtime.bgscavenge(0x0?)
/Users/bytedance/project/go/src/runtime/mgcscavenge.go:617 +0x45 fp=0xc000059fc8 sp=0xc000059fa0 pc=0x1026b65
runtime.gcenable.func2()
/Users/bytedance/project/go/src/runtime/mgc.go:179 +0x26 fp=0xc000059fe0 sp=0xc000059fc8 pc=0x101c826
runtime.goexit()
/Users/bytedance/project/go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000059fe8 sp=0xc000059fe0 pc=0x1071de1
created by runtime.gcenable
/Users/bytedance/project/go/src/runtime/mgc.go:179 +0xaa

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 12, 2022
@cuonglm
Copy link
Member

cuonglm commented Aug 12, 2022

Duplicated of #54411

@cuonglm cuonglm closed this as completed Aug 12, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/423294 mentions this issue: runtime/interal/atomic: don't allow splitting stack during system call

@golang golang locked and limited conversation to collaborators Aug 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants