fix: unaligned 64-bit atomic panic on 32-bit platforms in telemetry buffers#1355
Merged
giortzisg merged 1 commit intoJul 8, 2026
Merged
Conversation
…uffers RingBuffer and BucketedBuffer kept their offered/dropped counters as plain int64 fields in the middle of the struct and updated them with atomic.AddInt64. On 32-bit platforms (GOARCH=arm, GOARCH=386) struct fields are only 4-byte aligned, while 64-bit sync/atomic operations require 8-byte alignment, so every Offer call — i.e. every event capture — panicked with "unaligned 64-bit atomic operation". Use atomic.Int64 instead: its alignment is guaranteed by the runtime regardless of field position. Reproducible with GOARCH=386 go test ./internal/telemetry/ before this change. Fixes getsentry#1354 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1355 +/- ##
==========================================
- Coverage 86.04% 78.46% -7.59%
==========================================
Files 62 87 +25
Lines 6090 8032 +1942
==========================================
+ Hits 5240 6302 +1062
- Misses 635 1431 +796
- Partials 215 299 +84 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
giortzisg
approved these changes
Jul 8, 2026
17 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On 32-bit platforms (
GOARCH=arm,GOARCH=386), every event capture panics withunaligned 64-bit atomic operation: theoffered/droppedcounters ofRingBufferandBucketedBufferare plainint64fields in the middle of the struct, and the compiler only guarantees them 4-byte alignment there, while 64-bitsync/atomicoperations require 8-byte alignment (see the "Bugs" section of thesync/atomicdocs). SinceClient.CaptureEventroutes throughRingBuffer.Offerby default, the SDK is effectively unusable on 32-bit ARM (e.g. Raspberry Pi) unlessDisableTelemetryBufferis set.This PR replaces the counters with
atomic.Int64, whose alignment is guaranteed by the runtime regardless of field position, so future struct refactorings can't reintroduce the panic.Verified with the existing test suite on a 32-bit target — before the change it reproduces the panic natively:
after the change:
go test ./...,go vet,gofmtare clean on amd64 as well.Issues
🤖 Generated with Claude Code