Skip to content

fix: unaligned 64-bit atomic panic on 32-bit platforms in telemetry buffers#1355

Merged
giortzisg merged 1 commit into
getsentry:masterfrom
Kirill-INQ:fix/unaligned-64bit-atomic-32bit
Jul 8, 2026
Merged

fix: unaligned 64-bit atomic panic on 32-bit platforms in telemetry buffers#1355
giortzisg merged 1 commit into
getsentry:masterfrom
Kirill-INQ:fix/unaligned-64bit-atomic-32bit

Conversation

@Kirill-INQ

Copy link
Copy Markdown
Contributor

Description

On 32-bit platforms (GOARCH=arm, GOARCH=386), every event capture panics with unaligned 64-bit atomic operation: the offered/dropped counters of RingBuffer and BucketedBuffer are plain int64 fields in the middle of the struct, and the compiler only guarantees them 4-byte alignment there, while 64-bit sync/atomic operations require 8-byte alignment (see the "Bugs" section of the sync/atomic docs). Since Client.CaptureEvent routes through RingBuffer.Offer by default, the SDK is effectively unusable on 32-bit ARM (e.g. Raspberry Pi) unless DisableTelemetryBuffer is 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:

$ GOARCH=386 go test ./internal/telemetry/
panic: unaligned 64-bit atomic operation
  ...
  github.com/getsentry/sentry-go/internal/telemetry.(*RingBuffer[...]).Offer(...)
      internal/telemetry/ring_buffer.go:75
FAIL

after the change:

$ GOARCH=386 go test ./internal/telemetry/
ok      github.com/getsentry/sentry-go/internal/telemetry

go test ./..., go vet, gofmt are clean on amd64 as well.

Issues

🤖 Generated with Claude Code

…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

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.46%. Comparing base (1ce3436) to head (b08daf9).
⚠️ Report is 149 commits behind head on master.

Files with missing lines Patch % Lines
internal/telemetry/bucketed_buffer.go 71.42% 2 Missing ⚠️
internal/telemetry/ring_buffer.go 83.33% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (1ce3436) and HEAD (b08daf9). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (1ce3436) HEAD (b08daf9)
9 1
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@giortzisg giortzisg merged commit 897af88 into getsentry:master Jul 8, 2026
19 of 20 checks passed
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.

panic: unaligned 64-bit atomic operation on 32-bit ARM (GOARCH=arm) — telemetry RingBuffer counters

2 participants