Skip to content

Fixed 64-bit alignment panic in the interim struct on 32-bit platforms - #437

Merged
Thejas-bhat merged 1 commit into
blevesearch:masterfrom
wu:fix-interim-alignment
Jul 23, 2026
Merged

Fixed 64-bit alignment panic in the interim struct on 32-bit platforms#437
Thejas-bhat merged 1 commit into
blevesearch:masterfrom
wu:fix-interim-alignment

Conversation

@wu

@wu wu commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

It's the same story as #147, #148, and #290, but for the v17 interim struct: bytesWritten is accessed atomically but sits at a 4-byte offset on 32-bit platforms, so the first segment write panics with unaligned 64-bit atomic operation.

We hit this on ARMv6 when upgrading bleve v2.5.7 → v2.6.0, the first bleve release that writes zapx/v17 segments. We've pinned bleve at v2.5.7 until a fixed v17 release is available.

Verified on ARMv6 hardware (CI runner on a 32-bit ARM SBC). Before this change, TestBuild panics:

--- FAIL: TestBuild (0.00s)
panic: unaligned 64-bit atomic operation [recovered, repanicked]
...
internal/runtime/atomic.panicUnaligned()
    /usr/local/go/src/internal/runtime/atomic/unaligned.go:8
internal/runtime/atomic.Xadd64(0x2cbc844, 0x17)
    /usr/local/go/src/internal/runtime/atomic/atomic_arm.s:319
github.com/blevesearch/zapx/v17.(*interim).incrementBytesWritten(...)
    new.go:334
github.com/blevesearch/zapx/v17.(*interim).writeStoredFields(0x2cbc7e0)
    new.go:408

With this change, the full test suite passes on the same runner (and on amd64 with -race).

While auditing the remaining atomic 64-bit call sites I found the same layout in vectorIndexOpaque.bytesWritten and cacheEntry.refs (vectors build) — happy to send a follow-up PR for those if useful.

@Thejas-bhat

Copy link
Copy Markdown
Member

@wu thanks for the contribution!

While auditing the remaining atomic 64-bit call sites I found the same layout in vectorIndexOpaque.bytesWritten and cacheEntry.refs (vectors build) — happy to send a follow-up PR for those if useful

yes, if you've tested out the fixes for the remaining call sites, feel free to open the follow up PRs, thanks!

@Thejas-bhat
Thejas-bhat merged commit edd64cb into blevesearch:master Jul 23, 2026
9 checks passed
@Thejas-bhat

Thejas-bhat commented Jul 23, 2026

Copy link
Copy Markdown
Member

@wu, we've merged these changes in, feel free to open the follow up ones

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.

3 participants