mirror of
https://github.com/golang/go
synced 2024-11-23 14:30:02 -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:
parent
67ce6af456
commit
526b2f85ce
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user