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: syscall.Syscall15: nosplit stack over 792 byte limit #69813

Closed
nicolasparada opened this issue Oct 8, 2024 · 7 comments
Closed
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@nicolasparada
Copy link

Go version

go version go1.23.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/nicolasparada/Library/Caches/go-build'
GOENV='/Users/nicolasparada/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/nicolasparada/go/pkg/mod'
GONOPROXY='github.com/chronosphereio'
GONOSUMDB='github.com/chronosphereio'
GOOS='darwin'
GOPATH='/Users/nicolasparada/go'
GOPRIVATE='github.com/chronosphereio'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/nicolasparada/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='redacted/modules/cli/go.mod'
GOWORK='redacted/go.work'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/q5/y_70l5z562s_jnbc0yhcwfww0000gn/T/go-build4129866876=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Run the following command to compile our program:

go build -o cli -trimpath -ldflags "-s -w" -gcflags "all=-C -l -B"

This is run inside goreleaser for all the major platforms.

What did you see happen?

Got the following message when building for windows/arm64 (GOOS=windows GOARCH=arm64).

$ GOOS=windows GOARCH=arm64 go build -o cli -trimpath -ldflags "-s -w" -gcflags "all=-C -l -B"

syscall.Syscall15: nosplit stack over 792 byte limit
syscall.Syscall15<1>
    grows 288 bytes, calls syscall.SyscallN<1>
        grows 48 bytes, calls runtime.cgocall<1>
            grows 112 bytes, calls runtime.entersyscall<1>
                grows 48 bytes, calls runtime.reentersyscall<1>
                    grows 112 bytes, calls runtime.save<1>
                        grows 32 bytes, calls runtime.badctxt<1>
                            grows 32 bytes, calls runtime.throw<1>
                                grows 48 bytes, calls runtime.fatalthrow<1>
                                    grows 64 bytes, calls runtime.systemstack<0>
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.abort<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls gosave_systemstack_switch<79>
                                            grows 0 bytes, calls runtime.abort<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                    grows 112 bytes, calls runtime.save<1>
                        grows 32 bytes, calls runtime.badctxt<1>
                            grows 32 bytes, calls runtime.throw<1>
                                grows 48 bytes, calls runtime.fatalthrow<1>
                                    grows 64 bytes, calls runtime.systemstack<0>
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.abort<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls gosave_systemstack_switch<79>
                                            grows 0 bytes, calls runtime.abort<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                    grows 112 bytes, calls runtime.save<1>
                        grows 32 bytes, calls runtime.badctxt<1>
                            grows 32 bytes, calls runtime.throw<1>
                                grows 48 bytes, calls runtime.fatalthrow<1>
                                    grows 64 bytes, calls runtime.systemstack<0>
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.abort<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls gosave_systemstack_switch<79>
                                            grows 0 bytes, calls runtime.abort<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                    grows 112 bytes, calls runtime.save<1>
                        grows 32 bytes, calls runtime.badctxt<1>
                            grows 32 bytes, calls runtime.throw<1>
                                grows 48 bytes, calls runtime.fatalthrow<1>
                                    grows 64 bytes, calls runtime.systemstack<0>
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.abort<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls gosave_systemstack_switch<79>
                                            grows 0 bytes, calls runtime.abort<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                    grows 112 bytes, calls runtime.save<1>
                        grows 32 bytes, calls runtime.badctxt<1>
                            grows 32 bytes, calls runtime.throw<1>
                                grows 48 bytes, calls runtime.fatalthrow<1>
                                    grows 64 bytes, calls runtime.systemstack<0>
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.abort<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls gosave_systemstack_switch<79>
                                            grows 0 bytes, calls runtime.abort<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit
                                        grows 16 bytes, calls indirect
                                            grows 0 bytes, calls runtime.morestack<0>
                                            8 bytes over limit
                                        grows 16 bytes, calls runtime.save_g<0>
                                        8 bytes over limit

What did you expect to see?

I expect no error, this was working fine before upgrading to Go 1.23.
Noticed that removing the -l flag from -gcflags does the trick and makes the program to compile no issues:

GOOS=windows GOARCH=arm64 go build -o cli -trimpath -ldflags "-s -w" -gcflags "all=-C -B"
@qmuntal qmuntal added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 8, 2024
@qmuntal
Copy link
Member

qmuntal commented Oct 8, 2024

Can reproduce the issue building the following program with go build on windows/amd64:

package main

import "syscall"

func main() {
	syscall.Syscall18(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
}

The change that introduced the excessive stack usage is CL 563315. I'll prepare a fix that can be backported.

@qmuntal qmuntal added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 8, 2024
@seankhliao seankhliao changed the title compiler: syscall.Syscall15: nosplit stack over 792 byte limit cmd/compile: syscall.Syscall15: nosplit stack over 792 byte limit Oct 8, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/618497 mentions this issue: runtime: reduce syscall.SyscallX stack usage

@qmuntal qmuntal self-assigned this Oct 8, 2024
@qmuntal qmuntal removed the NeedsFix The path to resolution is known, but the work has not been done. label Oct 8, 2024
@qmuntal
Copy link
Member

qmuntal commented Oct 11, 2024

@gopherbot Please backport to 1.23. This is a regression with no workaround.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #69848 (for 1.23).

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

@cagedmantis
Copy link
Contributor

Please create a backport CL for this issue.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/623516 mentions this issue: [release-branch.go1.23] runtime: reduce syscall.SyscallX stack usage

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 30, 2024
@dmitshur dmitshur added this to the Go1.24 milestone Oct 30, 2024
gopherbot pushed a commit that referenced this issue Oct 30, 2024
syscall.SyscallX consumes a lot of stack space, which is a problem
because they are nosplit functions. They used to use less stack space,
but CL 563315, that landed in Go 1.23, increased the stack usage by a
lot.

This CL reduces the stack usage back to the previous level.

Fixes #69848
Updates #69813

Change-Id: Iddedd28b693c66a258da687389768055c493fc2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/618497
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
(cherry picked from commit fa7343a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/623516
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Michael Pratt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

6 participants