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: simple programs crash on linux/386 with go1.21 when build with -gcflags='all=-N -l' #61975

Closed
aarzilli opened this issue Aug 12, 2023 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@aarzilli
Copy link
Contributor

$ go version
go version go1.21.0 linux/386

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

go env Output
$ go env
GO111MODULE=''
GOARCH='386'
GOBIN=''
GOCACHE='/home/d/.cache/go-build'
GOENV='/home/d/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='386'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/d/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/d/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/d/go121'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/d/go121/pkg/tool/linux_386'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GO386='sse2'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/d/delve/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m32 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3216151546=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Compile:

package main

import "fmt"

func main() {
        fmt.Println("hello world!")
}

with -gcflags='all=-N -l' and run the executable

What did you see instead?

runtime: newstack at runtime.traceEnabled+0x23 sp=0xa02c458 stack=[0xa02c000, 0xa02c800]
        morebuf={pc:0x808bdd5 sp:0xa02c45c lr:0x0}
        sched={pc:0x80a27e3 sp:0xa02c458 lr:0x0 ctxt:0x0}
runtime.reentersyscall(0x80d0200, 0xa02c488)
        /home/d/go121/src/runtime/proc.go:4024 +0xa5 fp=0xa02c47c sp=0xa02c45c pc=0x808bdd5
runtime.entersyscall()
        /home/d/go121/src/runtime/proc.go:4064 +0x17 fp=0xa02c488 sp=0xa02c47c pc=0x80ad8a7
syscall.Syscall(0x4, 0x1, 0xa0120d0, 0xd)
        /home/d/go121/src/syscall/syscall_linux.go:69 +0x20 fp=0xa02c4cc sp=0xa02c488 pc=0x80d0200
syscall.write(0x1, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/syscall/zsyscall_linux_386.go:949 +0x96 fp=0xa02c518 sp=0xa02c4cc pc=0x80cfd66
syscall.Write(0x1, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/syscall/syscall_unix.go:209 +0x65 fp=0xa02c550 sp=0xa02c518 pc=0x80cfa45
internal/poll.ignoringEINTRIO(0x80fa058, 0x1, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/internal/poll/fd_unix.go:736 +0x6c fp=0xa02c59c sp=0xa02c550 pc=0x80d260c
internal/poll.(*FD).Write(0xa042080, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/internal/poll/fd_unix.go:380 +0x29b fp=0xa02c678 sp=0xa02c59c pc=0x80d230b
os.(*File).write(0xa014130, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/os/file_posix.go:46 +0x6f fp=0xa02c6b8 sp=0xa02c678 pc=0x80d302f
os.(*File).Write(0xa014130, {0xa0120d0, 0xd, 0x10})
        /home/d/go121/src/os/file.go:183 +0xb5 fp=0xa02c700 sp=0xa02c6b8 pc=0x80d2c25
fmt.Fprintln({0x80fe8ac, 0xa014130}, {0xa02c7a0, 0x1, 0x1})
        /home/d/go121/src/fmt/print.go:305 +0xa5 fp=0xa02c748 sp=0xa02c700 pc=0x80d7335
fmt.Println({0xa02c7a0, 0x1, 0x1})
        /home/d/go121/src/fmt/print.go:314 +0x71 fp=0xa02c784 sp=0xa02c748 pc=0x80d7401
main.main()
        /home/d/delve/_fixtures/buildtest/main.go:6 +0x73 fp=0xa02c7b8 sp=0xa02c784 pc=0x80dc493
runtime.main()
        /home/d/go121/src/runtime/proc.go:267 +0x291 fp=0xa02c7f0 sp=0xa02c7b8 pc=0x8084121
runtime.goexit()
        /home/d/go121/src/runtime/asm_386.s:1363 +0x1 fp=0xa02c7f4 sp=0xa02c7f0 pc=0x80b0031
fatal error: runtime: stack split at bad time
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 12, 2023
aarzilli added a commit to aarzilli/delve that referenced this issue Aug 12, 2023
Programs built with `-gcflags='all=-N -l'` do not work on
linux/386/1.21 due to golang/go#61975
mauri870 added a commit to mauri870/go that referenced this issue Aug 12, 2023
The traceEnabled function splits the stack and is being
called by reentersyscall that shouldn't call anything
that splits the stack.

Fixes golang#61975
@mauri870
Copy link
Member

Looks like traceEnabled that was introduced in this CL grows the stack, it should be marked as no:split.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/519055 mentions this issue: runtime: mark traceEnabled as no:split

mauri870 added a commit to mauri870/go that referenced this issue Aug 12, 2023
The traceEnabled function splits the stack and is being
called by reentersyscall that shouldn't call anything
that splits the stack. Same with traceShuttingDown.

Fixes golang#61975
@aarzilli
Copy link
Contributor Author

@gopherbot, please backport to Go1.21, this is a regression.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #61987 (for 1.21).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

derekparker pushed a commit to go-delve/delve that referenced this issue Aug 14, 2023
Programs built with `-gcflags='all=-N -l'` do not work on
linux/386/1.21 due to golang/go#61975
@mauri870
Copy link
Member

cc @seankhliao

@dmitshur dmitshur added this to the Go1.22 milestone Aug 14, 2023
@dmitshur
Copy link
Contributor

CC @mknyszek.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Aug 14, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/519495 mentions this issue: [release-branch.go1.21] runtime: mark traceEnabled and traceShuttingDown as no:split

gopherbot pushed a commit that referenced this issue Aug 17, 2023
…own as no:split

This fixes a regression from CL 494181.
The traceEnabled function splits the stack and is being
called by reentersyscall that shouldn't call anything
that splits the stack. Same with traceShuttingDown.

For #61975
Fixes #61987

Change-Id: I5eca0ba74cfa6acb0259e8400b03c2093cd59dd1
GitHub-Last-Rev: 9e55ae9
GitHub-Pull-Request: #61981
Reviewed-on: https://go-review.googlesource.com/c/go/+/519055
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit aa5d483)
Reviewed-on: https://go-review.googlesource.com/c/go/+/519495
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants