Go version
go version go1.24.4 darwin/arm64
Output of go env
in your module/workspace:
N/A
What did you do?
While I ran into the issue in real code, it's somewhat obscure and impossible to reproduce using https://go.dev/play, since it requires passing -ldflags=-checklinkname=0
to go build
.
In short, I called sysReserveAlignedSbrk(65536, 0)
twice.
What did you see happen?
The lock taken here wasn't released during the first call, because this return is hit, leading to a panic in the second call.
What did you expect to see?
The lock to always be released, presumably by adding unlock(&memlock)
before each return.
It's not clear to me whether this is reachable without pull-mode linking of sysReserveAlignedSbrk
or sysReserveAligned
, since the former is only called by the latter, and the latter seems unused—but I might certainly be missing usages of either or both.
Comment From: gabyhelp
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/683295 mentions this issue: runtime: add missing unlock in sysReserveAlignedSbrk
Comment From: cherrymui
@gopherbot please backport this to Go 1.24. This could potentially cause a deadlock. The fix is obviously safe. Thanks.
(1.24 only as sysReserveAlignedSbrk is new code in 1.24.)
Comment From: gopherbot
Backport issue(s) opened: #74346 (for 1.24).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.