go: runtime: crash since Go 1.22.5 on Alpine (newstack at runtime.printlock)

Go version

go version go1.22.5 linux/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.22.5'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/go/src/app/go.mod'
GOWORK=''
CGO_CFLAGS='-DFRANKENPHP_VERSION=v1.2.1 -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
CGO_CPPFLAGS='-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-lssl -lcrypto -lreadline -largon2 -lcurl -lonig -lz -Wl,-O1 -pie'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2366048768=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Reproducer:

docker pull dunglas/frankenphp:1-builder-alpine
docker run -it dunglas/frankenphp:1-builder-alpine sh
go test

What did you see happen?

runtime: newstack at runtime.printlock+0x78 sp=0x4000167be0 stack=[0x4000166000, 0x4000168000]
        morebuf={pc:0x407920 sp:0x4000167be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000167be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(runtime: newstack at runtime.printlock+0x78 sp=0x4000365be0 stack=[0x4000364000, 0x4000366000]
        morebuf={pc:0x407920 sp:0x4000365be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000365be0 lr:0x407920 ctxt:0x0}
runtime: newstack at runtime.printlock+0x78 sp=0x4000361be0 stack=[0x4000360000, 0x4000362000]
        morebuf={pc:0x407920 sp:0x4000361be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000361be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x4000501808, 0xffff44e1fb80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000361c40 sp=0x4000361be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44e1fc70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000361cc0 sp=0x4000361c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44e1fc70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000361cf0 sp=0x4000361cc0 pc=0x47b1bc
runtime.cgocallback(0x4000361d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000361d20 sp=0x4000361cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000361d30 sp=0x4000361d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000361da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000361d70 sp=0x4000361d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff43eb29c0)
        _cgo_gotypes.go:791 +0x34 fp=0x4000361da0 sp=0x4000361d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x76ab01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000361e10 sp=0x4000361da0 pc=0x6dd7ccruntime: newstack at runtime.printlock+0x78 sp=0x4000165be0 stack=[0x4000164000, 0x4000166000]
        morebuf={pc:0x407920 sp:0x4000165be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000165be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x40001e4808, 0xffff44b07b80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000165c40 sp=0x4000165be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44b07c70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000165cc0 sp=0x4000165c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44b07c70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000165cf0 sp=0x4000165cc0 pc=0x47b1bc
runtime.cgocallback(0x4000165d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000165d20 sp=0x4000165cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000165d30 sp=0x4000165d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000165da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000165d70 sp=0x4000165d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff4477cb60)
        _cgo_gotypes.go:791 +0x34 fp=0x4000165da0 sp=0x4000165d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x4000165e01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000165e10 sp=0x4000165da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x4000165e88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000165e30 sp=0x4000165e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44b0a5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000165f00 sp=0x4000165e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44b0a5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000165f80 sp=0x4000165f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44b0a5e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000165fb0 sp=0x4000165f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000165fe0 sp=0x4000165fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000165fe0 sp=0x4000165fe0 pc=0x479724
fatal error: runtime: stack split at bad time
runtime: newstack at runtime.printlock+0x78 sp=0x4000459be0 stack=[0x4000458000, 0x400045a000]
        morebuf={pc:0x407920 sp:0x4000459be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000459be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x4000400808, 0xffff44eabb80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000459c40 sp=0x4000459be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44eabc70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000459cc0 sp=0x4000459c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44eabc70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000459cf0 sp=0x4000459cc0 pc=0x47b1bc
runtime.cgocallback(0x4000459d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000459d20 sp=0x4000459cf0 pc=0x479630
runtime.systemstack_switch
_cgoexp_a0107ffcccc7_go_execute_script(0x4000494e88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000361e30 sp=0x4000361e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44e225e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000361f00 sp=0x4000361e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44e225e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000361f80 sp=0x4000361f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44e225e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000361fb0 sp=0x4000361f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000361fe0 sp=0x4000361fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000361fe0 sp=0x4000361fe0 pc=0x479724
fatal error: runtime: stack split at bad time
0x4000500008, 0xffff44bb6b80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000167c40 sp=0x4000167be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44bb6c70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000167cc0 sp=0x4000167c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44bb6c70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000167cf0 sp=0x4000167cc0 pc=0x47b1bc
runtime.cgocallback(0x4000167d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000167d20 sp=0x4000167cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000167d30 sp=0x4000167d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000167da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000167d70 sp=0x4000167d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff44ee3430)
        _cgo_gotypes.go:791 +0x34 fp=0x4000167da0 sp=0x4000167d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x4000490e01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000167e10 sp=0x4000167da0 pc=0x6dd7cc
runtime.callbackUpdateSystemStack(0x400009a808, 0xffff44b70b80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000365c40 sp=0x4000365be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44b70c70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000365cc0 sp=0x4000365c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44b70c70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000365cf0 sp=0x4000365cc0 pc=0x47b1bc
runtime.cgocallback(0x4000365d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130_cgoexp_a0107ffcccc7_go_execute_script +0xb0 fp=0x4000365d20 sp=0x4000365cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000365d30 sp=0x4000365d20 pc=0x4771f8
(runtime: newstack at runtime.printlock+0x78 sp=0x4000251be0 stack=[0x4000250000, 0x4000252000]
        morebuf={pc:0x407920 sp:0x4000251be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000251be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x4000300808, 0xffff44bfcb80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000251c40 sp=0x4000251be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44bfcc70, runtime: newstack at runtime.printlock+0x78 sp=0x4000253be0 stack=[0x4000252000, 0x4000254000]
        morebuf={pc:0x407920 sp:0x4000253be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000253be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x4000500808, 0xffff44e88b80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000253c40 sp=0x4000253be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44e88c70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000253cc0 sp=0x4000253c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44e88c70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000253cf0 sp=0x4000253cc0 pc=0x47b1bc
runtime.cgocallback(0x4000253d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000253d20 sp=0x4000253cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000253d30 sp=0x4000253d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000253da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000253d70 sp=0x4000253d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff43b57b20)
        _cgo_gotypes.go:791 +0x34 fp=0x4000253da0 sp=0x4000253d70 pc=0x6dad64
0x4000490e88github.com/dunglas/frankenphp.go_execute_script(0x40002d0e01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000253e10 sp=0x4000253da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x8309c0?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000253e30 sp=0x4000253e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44e8b5e0, runtime: newstack at runtime.printlock+0x78 sp=0x4000255be0 stack=[0x4000254000, 0x4000256000]
        morebuf={pc:0x407920 sp:0x4000255be0 lr:0x0}
        sched={pc:0x43f858 sp:0x4000255be0 lr:0x407920 ctxt:0x0}
runtime.callbackUpdateSystemStack(0x4000480808, 0xffff44bd9b80, 0x0)
        /usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x4000255c40 sp=0x4000255be0 pc=0x407920
runtime.cgocallbackg(0x6e1a90, 0xffff44bd9c70, 0x0)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000255cc0 sp=0x4000255c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44bd9c70, 0x0)
        <autogenerated>:1?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000167e30 sp=0x4000167e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44bb95e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000167f00 sp=0x4000167e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44bb95e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000167f80 sp=0x4000167f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44bb95e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000167fb0 sp=0x4000167f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000167fe0 sp=0x4000167fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000167fe0 sp=0x4000167fe0 pc=0x479724
fatal error: runtime: stack split at bad time
()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000459d30 sp=0x4000459d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000459da8)
        /usr/local/go/src/runtime/cgocall.go:1750x0 +0x70 fp=0x4000459d70 sp=0x4000459d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff43bfa450)
        _cgo_gotypes.go:791 +0x34 fp=0x4000459da0 sp=0x4000459d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x40001cfe01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000459e10 sp=0x4000459da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x40001cfe88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000459e30 sp=0x4000459e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44eae5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000459f00 sp=0x4000459e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44eae5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000459f80 sp=0x4000459f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44eae5e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000459fb0 sp=0x4000459f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000459fe0 sp=0x4000459fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000459fe0 sp=0x4000459fe0 pc=0x479724
fatal error: runtime: stack split at bad time
runtime.cgocall(0x739e70, 0x4000365da8)
0x0     /usr/local/go/src/runtime/cgocall.go:175 +0x70)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000253f00 sp=0x4000253e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44e8b5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000253f80 sp=0x4000253f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44e8b5e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000253fb0 sp=0x4000253f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000253fe0 sp=0x4000253fb0 pc=0x479630
 fp=0x4000365d70 sp=0x4000365d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff43f6eb10)
        _cgo_gotypes.go:791 +0x34 fp=0x4000365da0 sp=0x4000365d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x40000dde01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000365e10 sp=0x4000365da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x40000dde88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000365e30 sp=0x4000365e10 pc=0x6e1670
)
        /usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x4000251cc0 sp=0x4000251c40 pc=0x407ae8
runtime.cgocallbackg(0x6e1a90, 0xffff44bfcc70, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000251cf0 sp=0x4000251cc0 pc=0x47b1bc
runtime.cgocallback(0x4000251d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000251d20 sp=0x4000251cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000251d30 sp=0x4000251d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000251da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000251d70 sp=0x4000251d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff44618050)
        _cgo_gotypes.go:791 +0x34 fp=0x4000251da0 sp=0x4000251d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x40002c3e01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000251e10 sp=0x4000251da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x40002c3e88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000251e30 sp=0x4000251e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44bff5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000251f00 sp=0x4000251e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44bff5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000251f80 sp=0x4000251f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44bff5e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000251fb0 sp=0x4000251f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000251fe0 sp=0x4000251fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000251fe0 sp=0x4000251fe0 pc=0x479724
fatal error: runtime: stack split at bad time
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000253fe0 sp=0x4000253fe0 pc=0x479724
fatal error: runtime: stack split at bad time
runtime.cgocallbackg1(0x6e1650, 0xffff44b735e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000365f00 sp=0x4000365e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44b735e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000365f80 sp=0x4000365f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44b735e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000365fb0 sp=0x4000365f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000365fe0 sp=0x4000365fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000365fe0 sp=0x4000365fe0 pc=0x479724
fatal error: runtime: stack split at bad time
 +0x1c fp=0x4000255cf0 sp=0x4000255cc0 pc=0x47b1bc
runtime.cgocallback(0x4000255d68, 0x6dad64, 0x739e70)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000255d20 sp=0x4000255cf0 pc=0x479630
runtime.systemstack_switch()
        /usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x4000255d30 sp=0x4000255d20 pc=0x4771f8
runtime.cgocall(0x739e70, 0x4000255da8)
        /usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x4000255d70 sp=0x4000255d30 pc=0x407830
github.com/dunglas/frankenphp._Cfunc_frankenphp_execute_script(0xffff446ca1d0)
        _cgo_gotypes.go:791 +0x34 fp=0x4000255da0 sp=0x4000255d70 pc=0x6dad64
github.com/dunglas/frankenphp.go_execute_script(0x4000495e01?)
        /go/src/app/frankenphp.go:511 +0x11c fp=0x4000255e10 sp=0x4000255da0 pc=0x6dd7cc
_cgoexp_a0107ffcccc7_go_execute_script(0x4000495e88?)
        _cgo_gotypes.go:923 +0x20 fp=0x4000255e30 sp=0x4000255e10 pc=0x6e1670
runtime.cgocallbackg1(0x6e1650, 0xffff44bdc5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x4000255f00 sp=0x4000255e30 pc=0x407e68
runtime.cgocallbackg(0x6e1650, 0xffff44bdc5e0, 0x0)
        /usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x4000255f80 sp=0x4000255f00 pc=0x407b8c
runtime.cgocallbackg(0x6e1650, 0xffff44bdc5e0, 0x0)
        <autogenerated>:1 +0x1c fp=0x4000255fb0 sp=0x4000255f80 pc=0x47b1bc
runtime.cgocallback(0x0, 0x0, 0x0)
        /usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x4000255fe0 sp=0x4000255fb0 pc=0x479630
runtime.goexit({})
        /usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000255fe0 sp=0x4000255fe0 pc=0x479724
fatal error: runtime: stack split at bad time

runtime stack:
runtime.throw({0x805cd1?, 0xffff44b07a10?})
        /usr/local/go/src/runtime/panic.go:1023 +0x40 fp=0xffff44b079c0 sp=0xffff44b07990 pc=0x43cf70
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:995 +0x7d0 fp=0xffff44b07b70 sp=0xffff44b079c0 pc=0x45b6d0
runtime.morestack()
        /usr/local/go/src/runtime/asm_arm64.s:341 +0x70 fp=0xffff44b07b70 sp=0xffff44b07b70 pc=0x477380

...

exit status 2

Full stack trace: https://github.com/dunglas/frankenphp/actions/runs/9778553362/job/26995650580?pr=898

What did you expect to see?

No crash.

The test suite wasn’t crashing with previous Go versions. It also doesn’t crash on Debian and macOS, only Alpine (musl?) is affected.

The project (FrankenPHP) heavily relies on cgo. We change the default Alpine stack trace -ldflags "-w -s -extldflags '-Wl,-z,stack-size=0x80000'. The binary is compressed with UPX.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 35 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Ran into a similar issue with boosts fibers (from c++) where applying 600296 helped us. Glad to see the fix is now merged to master 🎉

CL 600296 implements the update+restore logic. Could you try if this works with your case? Thanks.

@chenxiaolong thanks. We could add __BIONIC__ to the condition. We don’t seem to have a policy for which versions of Android we support. Do we require API level 34 for Android? Is there a way to check the API version with a macro? Or, is pthread_getattr_np supported long enough that we can assume it is available on all Android?

I took a quick look and I think we should be good with unconditionally enabling it for Android. pthread_getattr_np existed since at least API level 3 (in NDK version r9d, the oldest I could find). If needed, there is a __ANDROID_API__ macro that evaluates to the API version as an integer.

When I was originally approaching this problem (before I simply deleted the check to see how it crashed – it didn’t), my idea was to “trick” go into thinking it was a C1’ to G1’ type call via a stack – probably a less refined version of what you are thinking. My thinking was that we could basically ignore the original G1 call until we returned back to C2.

I don’t think we can just skip the bounds check. If C1 calls Go1, which calls C2, which calls Go2, if at Go2 (where mp.ncgo > 0) we update the bounds, when Go2 and C2 return, Go1 will see incorrect bounds and may panic. So I suggested we restore the old bounds, i.e. keep a stack of bounds. If cgo calls/callbacks are well nested, this probably will work. If they are not well nested (e.g. longjmp across Go frames), it won’t work, but it may already not work well anyway. I’ll try implementing this and see.

I created a custom Go build that reverts 3560cf0afb3c29300a6c88ccd98256949ca7a6f6, and this makes our test suite green. So I can confirm that the problem has been introduced by this commit: https://github.com/dunglas/frankenphp/actions/runs/9877453302/job/27279127840?pr=913

Would it be possible to revert it while a better fix isn’t available? I’m not confident relying on a custom build, and the latest patch version contains security fixes in net/http that are necessary for our use cases.