diff options
| author | Austin Clements <austin@google.com> | 2015-01-29 11:54:45 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2015-01-29 17:34:40 +0000 |
| commit | 7a71726b1f0b54b9241730e4bf7a5073676f17fa (patch) | |
| tree | c9f9c463bdbf18a82456170ca1adf9739552e418 /src/runtime/runtime.go | |
| parent | 83c10b204d619d18100716c9588404200acdf6e0 (diff) | |
| download | go-7a71726b1f0b54b9241730e4bf7a5073676f17fa.tar.xz | |
runtime: check alignment of 8-byte atomic loads and stores on 386
Currently, if we do an atomic{load,store}64 of an unaligned address on
386, we'll simply get a non-atomic load/store. This has been the
source of myriad bugs, so add alignment checks to these two
operations. These checks parallel the equivalent checks in
sync/atomic.
The alignment check is not necessary in cas64 because it uses a locked
instruction. The CPU will either execute this atomically or raise an
alignment fault (#AC)---depending on the alignment check flag---either
of which is fine.
This also fixes the two places in the runtime that trip the new
checks. One is in the runtime self-test and shouldn't have caused
real problems. The other is in tickspersecond and could, in
principle, have caused a misread of the ticks per second during
initialization.
Change-Id: If1796667012a6154f64f5e71d043c7f5fb3dd050
Reviewed-on: https://go-review.googlesource.com/3521
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/runtime.go')
| -rw-r--r-- | src/runtime/runtime.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go index 2ce4618f3f..ba9881fd91 100644 --- a/src/runtime/runtime.go +++ b/src/runtime/runtime.go @@ -10,6 +10,7 @@ import _ "unsafe" // for go:linkname var ticks struct { lock mutex + pad uint32 // ensure 8-byte alignment of val on 386 val uint64 } |
