]> Cypherpunks repositories - gostls13.git/commit
runtime: fix self-deadlock on sbrk platforms
authorMichael Anthony Knyszek <mknyszek@google.com>
Tue, 7 Oct 2025 16:10:19 +0000 (16:10 +0000)
committerMichael Knyszek <mknyszek@google.com>
Tue, 7 Oct 2025 17:33:18 +0000 (10:33 -0700)
commit11d5484190f80823c9b6312fd40f6491e864111b
treeefb21c64e66e46d3132501d4d00196bee340b082
parent2e52060084ff170097347457525f0debde91aea9
runtime: fix self-deadlock on sbrk platforms

The sbrk mem.go implementation doesn't enforce being called on the
systemstack, but it can call back into itself if there's a stack growth.
Because the sbrk implementation requires acquiring memlock, it can
self-deadlock.

For the most part the mem.go API is called on the system stack, but
there are cases where we call sysAlloc on the regular Go stack. This is
fine in general, except on sbrk platforms because of the aforementioned
deadlock.

This change, rather than adding a new invariant to mem.go, switches to
the systemstack in the mem.go API implementation for sbrk platforms.

Change-Id: Ie0f0ea80a8d7578cdeabc8252107e64a5e633856
Reviewed-on: https://go-review.googlesource.com/c/go/+/709775
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/mem_sbrk.go