]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: always lock OS thread in debugcall
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 3 Aug 2023 20:53:52 +0000 (20:53 +0000)
committerCherry Mui <cherryyz@google.com>
Thu, 7 Sep 2023 15:25:07 +0000 (15:25 +0000)
commitd9a4b24a1775c4c5baa4ce3005cb5af61346198e
tree48dec193fbe903157bc14c0f2ac86b8bad171b14
parentfb5bdb4cc94d23209d77a73c4148b3f9fbb10173
runtime: always lock OS thread in debugcall

Right now debuggers like Delve rely on the new goroutine created to run
a debugcall function to run on the same thread it started on, up until
it hits itself with a SIGINT as part of the debugcall protocol.

That's all well and good, except debugCallWrap1 isn't particularly
careful about not growing the stack. For example, if the new goroutine
happens to have a stale preempt flag, then it's possible a stack growth
will cause a roundtrip into the scheduler, possibly causing the
goroutine to switch to another thread.

Previous attempts to just be more careful around debugCallWrap1 were
helpful, but insufficient. This change takes everything a step further
and always locks the debug call goroutine and the new goroutine it
creates to the OS thread.

For #61732.

Change-Id: I038f3a4df30072833e27e6a5a1ec01806a32891f
Reviewed-on: https://go-review.googlesource.com/c/go/+/515637
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/runtime/debugcall.go