-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Fix PR #150116 bug: incorrect memory index inversion in coroutine layout #150266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+232
−7
Conversation
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
…utine layout This commit fixes a critical bug introduced in PR rust-lang#150116 that caused "offset is not a multiple of 16" errors when compiling for x86_64-unknown-uefi. Problem: -------- PR rust-lang#150116 optimized memory layout by inverting the storage representation from `memory_index` (source→memory) to `in_memory_order` (memory→source). However, in compiler/rustc_abi/src/layout/coroutine.rs (lines 244-276), the code was building `combined_in_memory_order` directly instead of: 1. Building `combined_memory_index` (source→memory) first 2. Inverting it to get `in_memory_order` (memory→source) This caused fields to be placed at incorrect offsets, violating PE/COFF alignment requirements (16-byte multiples), triggering linker errors. Solution: --------- Changed the coroutine layout code to: - Build `combined_memory_index` as an intermediate representation - Use correct indexing: `combined_memory_index[i] = memory_index` - Invert at the end: `combined_in_memory_order = combined_memory_index.invert_bijective_mapping()` Impact: ------- - Fixes UEFI target compilation (x86_64-unknown-uefi) - May affect other PE/COFF targets - Enables SOBEX OS development to continue Files changed: -------------- - compiler/rustc_abi/src/layout/coroutine.rs: Applied fix - BUG_FIX_REPORT.md: Detailed investigation report - fix_pr150116_coroutine_layout.patch: Patch for upstream submission - .gitignore: Added Claude Code settings Upstream: --------- This fix should be submitted to rust-lang/rust as it affects the latest nightly (2025-12-19) and potentially other PE/COFF targets. 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Collaborator
Collaborator
|
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Member
|
Closed as per rust-lang/compiler-team#893 |
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.
This commit fixes a critical bug introduced in PR #150116 that caused "offset is not a multiple of 16" errors when compiling for x86_64-unknown-uefi.
Problem:
PR #150116 optimized memory layout by inverting the storage representation from
memory_index(source→memory) toin_memory_order(memory→source).However, in compiler/rustc_abi/src/layout/coroutine.rs (lines 244-276), the code was building
combined_in_memory_orderdirectly instead of:combined_memory_index(source→memory) firstin_memory_order(memory→source)This caused fields to be placed at incorrect offsets, violating PE/COFF alignment requirements (16-byte multiples), triggering linker errors.
Solution:
Changed the coroutine layout code to:
combined_memory_indexas an intermediate representationcombined_memory_index[i] = memory_indexcombined_in_memory_order = combined_memory_index.invert_bijective_mapping()Impact:
Files changed:
Upstream:
This fix should be submitted to rust-lang/rust as it affects the latest nightly (2025-12-19) and potentially other PE/COFF targets.
🤖 Generated with Claude Code