Skip to content

Fix i386 alignment for objects with MemAlign-sized custom alignment#25524

Closed
Copilot wants to merge 3 commits intopr_Kastefrom
copilot/sub-pr-25520
Closed

Fix i386 alignment for objects with MemAlign-sized custom alignment#25524
Copilot wants to merge 3 commits intopr_Kastefrom
copilot/sub-pr-25520

Conversation

Copy link
Contributor

Copilot AI commented Feb 16, 2026

On i386, MemAlign = 16 and sizeof(Cell) = 8. Allocating objects with 16-byte alignment used small chunks (because alignment <= MemAlign), which aligned the Cell pointer but not the user data at Cell + 8, causing alignment assertions to fail.

Changes

  • alloc.nim: Force big chunk allocation when alignment >= MemAlign (was > MemAlign)

    • Big chunks compute padding to align user data after both chunk and Cell headers
    • Updated bigChunkAlignOffset() to handle alignment == MemAlign case
  • gc.nim: Check cellToUsr() alignment when alignment >= MemAlign (was > MemAlign)

    • Ensures assertions validate user data alignment, not just Cell pointer alignment

The fix ensures that on 32-bit systems, objects with custom alignment equal to MemAlign are properly aligned after accounting for the 8-byte Cell header.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 16, 2026 10:40
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
On i386, MemAlign is 16 bytes and sizeof(Cell) is 8 bytes. When allocating
objects with 16-byte alignment using small chunks, the Cell pointer is
aligned to 16 bytes, but the user data (Cell + 8 bytes) is only aligned
to 8 bytes, causing alignment assertion failures.

The fix forces big chunk allocation when alignment >= MemAlign (not just >),
so that bigChunkAlignOffset can compute proper padding to account for both
BigChunk and Cell headers, ensuring user data is properly aligned.

Also updated assertions to check cellToUsr alignment when alignment >= MemAlign.

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI for i386 platform compatibility Fix i386 alignment for objects with MemAlign-sized custom alignment Feb 16, 2026
Copilot AI requested a review from ringabout February 16, 2026 10:49
@ringabout
Copy link
Member

@copilot domn

@ringabout ringabout closed this Feb 16, 2026
@ringabout ringabout deleted the copilot/sub-pr-25520 branch February 16, 2026 11:07
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