]> Cypherpunks repositories - gostls13.git/commit
runtime: print gctrace before releasing worldsema
authorAustin Clements <austin@google.com>
Mon, 14 Dec 2015 20:19:07 +0000 (15:19 -0500)
committerAustin Clements <austin@google.com>
Tue, 15 Dec 2015 17:58:30 +0000 (17:58 +0000)
commit1e1ea66991ce840d6f52cb8385e23624f16e9f01
tree603ab1b59dd7f8a7099c38e347342ed9e4e1e72d
parentff5c94538292ca66543603fc78c02a96c823c6aa
runtime: print gctrace before releasing worldsema

Currently we drop worldsema and then print the gctrace. We did this so
that if stderr is a pipe or a blocked terminal, blocking on printing
the gctrace would not block another GC from starting. However, this is
a bit of a fool's errand because a blocked runtime print will block
the whole M/P, so after GOMAXPROCS GC cycles, the whole system will
freeze. Furthermore, now this is much less of an issue because
allocation will block indefinitely if it can't start a GC (whereas it
used to be that allocation could run away). Finally, this allows
another GC cycle to start while the previous cycle is printing the
gctrace, which leads to races on reading various statistics to print
them and the next GC cycle overwriting those statistics.

Fix this by moving the release of worldsema after the gctrace print.

Change-Id: I3d044ea0f77d80f3b4050af6b771e7912258662a
Reviewed-on: https://go-review.googlesource.com/17812
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go