Commit 526b2f85 authored by Cherry Zhang's avatar Cherry Zhang

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 67ce6af4
......@@ -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)
......
......@@ -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)
}
......
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment