]> Cypherpunks repositories - gostls13.git/commit
runtime: test alignment of fields targeted by 64-bit atomics
authorKeith Randall <khr@golang.org>
Tue, 17 May 2022 22:52:20 +0000 (15:52 -0700)
committerKeith Randall <khr@golang.org>
Thu, 19 May 2022 20:10:40 +0000 (20:10 +0000)
commit6b6813fdb79d426c3693eef2cc423263185cb3a2
tree7923dcc44746c49751f7a243eb486691e105841f
parent9b89c380208ea2e85985ee6bf2b1d684274dfa1d
runtime: test alignment of fields targeted by 64-bit atomics

Make sure that all the targets of 64-bit atomic operations
are actually aligned to 8 bytes. This has been a source of
bugs on 32-bit systems. (e.g. CL 399754)

The strategy is to have a simple test that just checks the
alignment of some explicitly listed fields and global variables.

Then there's a more complicated test that makes sure the list
used in the simple test is exhaustive. That test has some
limitations, but it should catch most cases, particularly new
uses of atomic operations on new or existing fields.

Unlike a runtime assert, this check is free and will catch
accesses that occur even in very unlikely code paths.

Change-Id: I25ac78df471ac33b57cb91375bd8453d6ce2814f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407034
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/runtime/align_runtime_test.go [new file with mode: 0644]
src/runtime/align_test.go [new file with mode: 0644]
src/runtime/mgc.go
src/runtime/runtime.go