Skip to content

Fix Windows/UEFI handling for non-ZST sentinels in distributed slices#126

Merged
dtolnay merged 1 commit intodtolnay:masterfrom
AaronRM:fix-windows-zst-minimal
Apr 17, 2026
Merged

Fix Windows/UEFI handling for non-ZST sentinels in distributed slices#126
dtolnay merged 1 commit intodtolnay:masterfrom
AaronRM:fix-windows-zst-minimal

Conversation

@AaronRM
Copy link
Copy Markdown
Contributor

@AaronRM AaronRM commented Apr 16, 2026

On Windows (and UEFI), distributed_slice relies on ZST statics (() and [T; 0]) occupying exactly 0 bytes in PE/COFF grouped sections, but this is not guaranteed by the language and breaks with some codegen backends (#125). ZST sections are also fragile in other ways: rust-lld crashes on empty slices (#114) and MinGW's linker garbage-collects them (#25).

This PR replaces the ZST sentinels with non-ZST types of known size -- MaybeUninit<T> for slice boundaries and isize for dupcheck boundaries -- then adjusts the runtime arithmetic to account for the sentinel bytes: wrapping_add(2) for dupcheck and start.add(1) to skip the start sentinel.

All changes are behind cfg(windows/uefi) and do not affect other platforms.

Closes #125

Copy link
Copy Markdown
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dtolnay dtolnay merged commit b03451d into dtolnay:master Apr 17, 2026
15 checks passed
@AaronRM AaronRM deleted the fix-windows-zst-minimal branch April 17, 2026 15:42
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.

distributed_slice breaks on Windows when ZST sentinels occupy non-zero bytes in PE sections

2 participants