]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: don't take allglock in tracebackothers
authorMichael Pratt <mpratt@google.com>
Tue, 17 Nov 2020 16:55:53 +0000 (11:55 -0500)
committerMichael Pratt <mpratt@google.com>
Tue, 5 Jan 2021 20:00:43 +0000 (20:00 +0000)
commit6b37b15d9520f9fa2b819e66a37fac4b2d08da78
treee9870c709e116c1cc9fba45b3e702bb5ccd753fb
parent9eef49cfa6eb016e3b20df189e540c6c5a71f365
runtime: don't take allglock in tracebackothers

tracebackothers is called from fatal throw/panic.

A fatal throw may be taken with allglock held (notably in the allocator
when allglock is held), which would cause a deadlock in tracebackothers
when we try to take allglock again. Locking allglock here is also often
a lock order violation w.r.t. the locks held when throw was called.

Avoid the deadlock and ordering issues by skipping locking altogether.
It is OK to miss concurrently created Gs (which are generally avoided by
freezetheworld(), and which were possible previously anyways if created
after the loop).

Fatal throw/panic freezetheworld(), which should freeze other threads
that may be racing to modify allgs. However, freezetheworld() does _not_
guarantee that it stops all other threads, so we can't simply drop the
lock.

Fixes #42669
Updates #43175

Change-Id: I657aec46ed35fd5d1b3f1ba25b500128ab26b088
Reviewed-on: https://go-review.googlesource.com/c/go/+/270861
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>
src/runtime/mgcmark.go
src/runtime/proc.go
src/runtime/runtime2.go
src/runtime/traceback.go