panic: unaligned 64-bit atomic operation
zllovesuki opened this issue · 2 comments
zllovesuki commented
attempting to use skipmap on an arm build (with GOARM=7, GOARCH=arm, go version 1.17.8) gave such panic:
panic: unaligned 64-bit atomic operation
goroutine 1 [running]:
runtime/internal/atomic.panicUnaligned()
/usr/local/go/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Load64(0xd3e9cc)
/usr/local/go/src/runtime/internal/atomic/atomic_arm.s:286 +0x14
github.com/zhangyunhao116/skipmap.(*StringMap).randomlevel(0xd3e9c0)
/home/rachel/go/pkg/mod/github.com/zhangyunhao116/skipmap@v0.7.0/types.go:8919 +0x34
github.com/zhangyunhao116/skipmap.(*StringMap).LoadOrStoreLazy(0xd3e9c0, {0xd21270, 0xf}, 0x541ca8)
/home/rachel/go/pkg/mod/github.com/zhangyunhao116/skipmap@v0.7.0/types.go:9081 +0x20
skipmap version is v0.7.0 as i'm on go <1.18
Perhaps we can add some padding around these fields? or maybe rearrange the fields so they are aligned:
// StringMap represents a map based on skip list.
type StringMap struct {
header *stringNode
length int64
highestLevel int64 // highest level for now
}
... and for the nodes
zhangyunhao116 commented
Thanks for reporting this issue!
The problem has been fixed in branch oldversion
. We can use go get github.com/zhangyunhao116/skipmap@oldversion
to reinstall it. (This problem does not exist if version >= v0.8.0
)
zllovesuki commented
I can confirm that moving fields around fixed the panic.