sim: Fix STATUS_ACCESS_VIOLATION on Windows x86_64 #2771
Open
josesimoes wants to merge 3 commits into
Open
Conversation
josesimoes
force-pushed
the
sim-context-windows
branch
from
June 19, 2026 11:57
de97598 to
7057338
Compare
Contributor
Author
|
Pinging @d3zd3z in case this slipped through the cracks... |
d3zd3z
requested changes
Jul 9, 2026
The C `jmp_buf` embedded in this FFI struct needs 16-byte alignment under mingw's setjmp (saves XMM registers with movaps). The C compiler aligns the struct to 16 to satisfy that, but Rust's repr(C) only picked the 8-byte alignment of [u64; 48], so the field could land 8-byte aligned and setjmp faulted with STATUS_ACCESS_VIOLATION. Signed-off-by: José Simões <jose.simoes@eclo.solutions>
josesimoes
force-pushed
the
sim-context-windows
branch
from
July 9, 2026 07:56
7057338 to
e0e086c
Compare
- Removed the cfg_attr conditionals so it windows-msvc too. - Added a compile-time assertion to document the invariant and will fail the build if a future field reorder/addition ever regresses alignment below 16 bytes. Works on all platforms. Signed-off-by: José Simões <jose.simoes@eclo.solutions>
josesimoes
force-pushed
the
sim-context-windows
branch
from
July 9, 2026 14:33
e0e086c to
cdd833a
Compare
d3zd3z
reviewed
Jul 9, 2026
Signed-off-by: José Simões <jose.simoes@eclo.solutions>
Contributor
Author
|
@d3zd3z anything missing here? |
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.
The C
jmp_bufembedded in this FFI struct needs 16-byte alignment under mingw's setjmp (saves XMM registers with movaps). The C compiler aligns the struct to 16 to satisfy that, but Rust's repr(C) only picked the 8-byte alignment of [u64; 48], so the field could land 8-byte aligned and setjmp faulted with STATUS_ACCESS_VIOLATION.