Merge pull request #1888 from wnienhaus/fix-unaligned-atomic-operation-on-arm32

move uint64s to beginning of struct to ensure they are 64-bit aligned
This commit is contained in:
Phil Davis
2021-04-03 12:48:14 +05:45
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
Bugfix: Fixes "unaligned 64-bit atomic operation" panic on 32-bit ARM
sync/cache had uint64s that were not 64-bit aligned causing panics
on 32-bit systems during atomic access
https://github.com/owncloud/ocis/pull/1888
https://github.com/owncloud/ocis/issues/1887

View File

@@ -8,10 +8,11 @@ import (
// Cache is a barebones cache implementation.
type Cache struct {
// capacity and length have to be the first words
// in order to be 64-aligned on 32-bit architectures.
capacity, length uint64 // access atomically
entries sync.Map
pool sync.Pool
capacity uint64
length uint64
}
// CacheEntry represents an entry on the cache. You can type assert on V.