1
0
mirror of https://github.com/golang/go synced 2024-11-23 16:20:04 -07:00

runtime/internal/atomic: crash on unaligned 64-bit ops on 32-bit MIPS

This check was originally implemented by Vladimir in
https://go-review.googlesource.com/c/31489/1/src/runtime/internal/atomic/atomic_mipsx.go#30
but removed due to my comment (Sorry!). This CL adds it back.

Fixes #17786.

Change-Id: I7ff4c2539fc9e2afd8199964b587a8ccf093b896
Reviewed-on: https://go-review.googlesource.com/33431
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Cherry Zhang 2016-11-21 18:23:12 -05:00
parent 67ce6af456
commit 526b2f85ce
3 changed files with 9 additions and 5 deletions

View File

@ -25,7 +25,11 @@ func spinUnlock(state *uint32)
//go:nosplit
func lockAndCheck(addr *uint64) {
// force dereference before taking lock
// ensure 8-byte alignement
if uintptr(unsafe.Pointer(addr))&7 != 0 {
addr = nil
}
// force dereference before taking lock
_ = *addr
spinLock(&lock.state)

View File

@ -87,8 +87,8 @@ func TestUnaligned64(t *testing.T) {
if unsafe.Sizeof(int(0)) != 4 {
t.Skip("test only runs on 32-bit systems")
}
case "amd64p32", "mips", "mipsle":
// amd64p32 and mips can handle unaligned atomics.
case "amd64p32":
// amd64p32 can handle unaligned atomics.
t.Skipf("test not needed on %v", runtime.GOARCH)
}

View File

@ -1401,8 +1401,8 @@ func TestUnaligned64(t *testing.T) {
if unsafe.Sizeof(int(0)) != 4 {
t.Skip("test only runs on 32-bit systems")
}
case "amd64p32", "mips", "mipsle":
// amd64p32 and mips can handle unaligned atomics.
case "amd64p32":
// amd64p32 can handle unaligned atomics.
t.Skipf("test not needed on %v", runtime.GOARCH)
}