Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

union: fix panic due to misalignment of struct field in 32 bit architectures

r-ricci67fd60275a61
diff --git a/backend/union/upstream/upstream.go b/backend/union/upstream/upstream.go
index 35b477f79..7b9f44fd2 100644
--- a/backend/union/upstream/upstream.go
+++ b/backend/union/upstream/upstream.go
@@ -24,6 +24,10 @@ var (
// Fs is a wrap of any fs and its configs
type Fs struct {
+ // In order to ensure memory alignment on 32-bit architectures
+ // when this field is accessed through sync/atomic functions,
+ // it must be the first entry in the struct
+ cacheExpiry int64 // usage cache expiry time
fs.Fs
RootFs fs.Fs
RootPath string
@@ -32,7 +36,6 @@ type Fs struct {
creatable bool
usage *fs.Usage // Cache the usage
cacheTime time.Duration // cache duration
- cacheExpiry int64 // usage cache expiry time
cacheMutex sync.RWMutex
cacheOnce sync.Once
cacheUpdate bool // if the cache is updating