]> Cypherpunks repositories - gostls13.git/commit
runtime: fix bitmap copying corner-cases
authorAustin Clements <austin@google.com>
Wed, 2 May 2018 18:46:00 +0000 (14:46 -0400)
committerAustin Clements <austin@google.com>
Mon, 21 May 2018 18:42:00 +0000 (18:42 +0000)
commitb88276da6626102801a3621839d8f198176816ce
treeb283edbcecd9c18bdbe90692d226101865510960
parent5095e5d8e2cec3d6209e733652ead8ddc20fc7c2
runtime: fix bitmap copying corner-cases

When an object spans heap arenas, its bitmap is discontiguous, so
heapBitsSetType unrolls the bitmap into the object itself and then
copies it out to the real heap bitmap. Unfortunately, since this code
path is rare, it had two unnoticed bugs related to the head and tail
of the bitmap:

1. At the head of the object, we were using hbitp as the destination
bitmap pointer rather than h.bitp, but hbitp points into the
*temporary* bitmap space (that is, the object itself), so we were
failing to copy the partial bitmap byte at the head of an object.

2. The core copying loop copied all of the full bitmap bytes, but
always drove the remaining word count down to 0, even if there was a
partial bitmap byte for the tail of the object. As a result, we never
wrote partial bitmap bytes at the tail of an object.

I found these by enabling out-of-place unrolling all the time. To
improve our chances of detecting these sorts of bugs in the future,
this CL mimics this by enabling out-of-place mode 50% of the time when
doubleCheck is enabled so that we test both in-place and out-of-place
mode.

Change-Id: I69e5d829fb3444be4cf11f4c6d8462c26dc467e8
Reviewed-on: https://go-review.googlesource.com/110995
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbitmap.go