Skip to content

Conversation

@gibmat
Copy link
Contributor

@gibmat gibmat commented Aug 18, 2025

Recently this library was packaged for use in Debian. On 32bit architectures, such as armhf, there's a panic when running tests:

--- FAIL: TestErrorMethods (0.00s)
panic: unaligned 64-bit atomic operation [recovered]
	panic: unaligned 64-bit atomic operation

goroutine 100 [running]:
testing.tRunner.func1.2({0x1e2a20, 0x250a90})
	/usr/lib/go-1.24/src/testing/testing.go:1734 +0x254
testing.tRunner.func1()
	/usr/lib/go-1.24/src/testing/testing.go:1737 +0x3d4
panic({0x1e2a20, 0x250a90})
	/usr/lib/go-1.24/src/runtime/panic.go:792 +0xfc
internal/runtime/atomic.panicUnaligned()
	/usr/lib/go-1.24/src/internal/runtime/atomic/unaligned.go:8 +0x24
internal/runtime/atomic.Xadd64(0xd292c4, 0x1)
	/usr/lib/go-1.24/src/internal/runtime/atomic/atomic_arm.s:318 +0x14
github.com/olekukonko/errors.(*Error).Increment(...)
	/tmp/autopkgtest-lxc.jaml3hhb/downtmp/autopkgtest_tmp/_build/src/github.com/olekukonko/errors/errors.go:914
github.com/olekukonko/errors.TestErrorMethods(0xdb4fc8)
	/tmp/autopkgtest-lxc.jaml3hhb/downtmp/autopkgtest_tmp/_build/src/github.com/olekukonko/errors/errors_test.go:126 +0x5e4
testing.tRunner(0xdb4fc8, 0x219920)
	/usr/lib/go-1.24/src/testing/testing.go:1792 +0x124
created by testing.(*T).Run in goroutine 1
	/usr/lib/go-1.24/src/testing/testing.go:1851 +0x448
FAIL	github.com/olekukonko/errors	0.101s

The fix is easy -- move the field used in the atomic operations to the beginning of the struct which will ensure proper alignment across all architectures.

Signed-off-by: Mathias Gibbens <gibmat@debian.org>
@olekukonko olekukonko merged commit 4cdaf8a into olekukonko:main Aug 18, 2025
1 check passed
@olekukonko
Copy link
Owner

@gibmat thank you for your contribution

@gibmat gibmat deleted the fix-atomic-panic branch August 18, 2025 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants