Fix i386 alignment for objects with MemAlign-sized custom alignment#25524
Closed
Fix i386 alignment for objects with MemAlign-sized custom alignment#25524
Conversation
Draft
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
Member
|
@copilot domn |
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.
On i386,
MemAlign = 16andsizeof(Cell) = 8. Allocating objects with 16-byte alignment used small chunks (becausealignment <= MemAlign), which aligned the Cell pointer but not the user data atCell + 8, causing alignment assertions to fail.Changes
alloc.nim: Force big chunk allocation when
alignment >= MemAlign(was> MemAlign)bigChunkAlignOffset()to handlealignment == MemAligncasegc.nim: Check
cellToUsr()alignment whenalignment >= MemAlign(was> MemAlign)The fix ensures that on 32-bit systems, objects with custom alignment equal to
MemAlignare 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.