You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
atomic.panicUnaligned will occur due to unaligned struct member size. This occurs since the size of the endpoints sync.Map is variable, depending on the machine word size. On 64-bit archs, sync.Map is 32 bytes. On 32-bit archs, sync.Map is 20 bytes - resulting in the misalignment of the subsequent members in the EndpointCache struct:
typeEndpointCachestruct {
endpoints sync.MapendpointLimitint64// size is used to count the number elements in the cache.// The atomic package is used to ensure this size is accurate when// using multiple goroutines.sizeint64
}
$ GOARCH=386 go run foo.go
size of EndpointCache.endpoints: 20
offset of EndpointCache.endpoints: 0
offset of EndpointCache.endpointLimit: 20
offset of EndpointCache.size: 28
panic: unaligned 64-bit atomic operation
goroutine 1 [running]:
runtime/internal/atomic.panicUnaligned()
/usr/lib/go-1.21/src/runtime/internal/atomic/unaligned.go:8 +0x2d
runtime/internal/atomic.Xadd64(0x9ca201c, 0x1)
/usr/lib/go-1.21/src/runtime/internal/atomic/atomic_386.s:125 +0x11
main.main()
/tmp/foo/foo.go:30 +0x1e6
exit status 2
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Describe the bug
atomic.panicUnaligned
will occur due to unaligned struct membersize
. This occurs since the size of theendpoints
sync.Map is variable, depending on the machine word size. On 64-bit archs, sync.Map is 32 bytes. On 32-bit archs, sync.Map is 20 bytes - resulting in the misalignment of the subsequent members in theEndpointCache
struct:Expected Behavior
No panic to occur.
Current Behavior
The following test fails on 32-bit archs:
Reproduction Steps
Force test to execute as a 32-bit GOARCH, e.g.
Possible Solution
Reorder the struct members so that the
size
member, which is used in atomic operations, is 64-bit aligned.Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
Compiler and Version used
go version go1.21.1 linux/amd64
Operating System and version
Linux xps15 6.5.0-21-generic #21-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 14:17:40 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: