Repository navigation
[wasm] Fix sharing of wbarrier card between los object and wbarrier roots - #118271
Merged
Merged
Conversation
…oots In the change disabling los section allocator on wasm (via sgen_los_enable_sections_allocator), we aligned these los objects to 512 bytes, which is the memory range mapped by a card byte. This alignment prevented two los objects having memory mapped to the same card. Sharing with other objects is impossible since they are allocated in separate spaces with high alignment (the nursery and major blocks). There was however an oversight, which is the possibility of having wbarrier roots allocated in this space (These roots are just variable sized memory ranges containing refs, that are scanned only if the corresponding card is marked). In this situation, scanning the cards for the los object could end up clearing cards for these roots that will no longer be scanned
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a potential issue in WebAssembly garbage collection where write barrier cards could be incorrectly shared between large object space (LOS) objects and write barrier roots, leading to missed reference scanning.
- Ensures LOS objects on WASM reserve the full card range to prevent sharing with write barrier roots
- Moves conditional compilation directives to improve code clarity and maintainability
Member
Author
Member
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
pavelsavara
approved these changes
Aug 1, 2025
This was referenced Aug 1, 2025
Closed
lewing
approved these changes
Aug 1, 2025
This was referenced Aug 5, 2025
Closed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In the change disabling los section allocator on wasm (via sgen_los_enable_sections_allocator), we aligned these los objects to 512 bytes, which is the memory range mapped by a card byte. This alignment prevented two los objects having memory mapped to the same card. Sharing with other objects is impossible since they are allocated in separate spaces with high alignment (the nursery and major blocks). There was however an oversight, which is the possibility of having wbarrier roots allocated in this space (These roots are just variable sized memory ranges containing refs, that are scanned only if the corresponding card is marked). In this situation, scanning the cards for the los object could end up clearing cards for these roots that will no longer be scanned.
We fix this by reserving the memory for the los object up to the full card range. We could alternatively fix this by adding alignment card size in the place where we allocate the wbarrier roots.