This repository was archived by the owner on Oct 4, 2022. It is now read-only.
In the spill slot allocator, set RangeFragAndRefness::is_ref to `tr…#86
Merged
julian-seward1 merged 1 commit intoJul 16, 2020
Conversation
cfallin
approved these changes
Jul 16, 2020
cfallin
left a comment
Member
There was a problem hiding this comment.
Looks good aside from one comment request -- thanks for the quick fix!
Merged
…ue` only when we know that a reftyped `VirtualRange` is going to be spilled. This fixes a conceptual error in stackmap generation found by Chris via fuzzing. The error was that `RangeFragAndRefness::is_ref` was previously set to `true` too early. Specifically, spill slots for all `VirtualRanges` of a virtual range equivalence class are allocated at the point where the first `VirtualRange` in the eclass was spilled. And the `RangeFragAndRefness::is_ref` of all `RangeFrag`s owned by the eclass was set to `true` if the `VirtualRange` was reftyped. From the point of view of "does this spill slot fragment carry a reftyped thing, or not?", that's exactly correct. However, it ignores the fact that other `VirtualRange`s in the same eclass ultimately might not be spilled. Hence the effect is to potentially mark some of those spill slot sections as reftyped even though they will never be used. Consequently the client could end up passing such slot sections to its GC for scavenging etc even though they contain undefined values. This could cause crashing or worse. The fix is (conceptually) very simple: don't set `RangeFragAndRefness::is_ref` to `true` when initially allocating spill slots. Instead, set it (them) later in the process, when spilling a `VirtualRange` that is reftyped. A new method, `SpillSlotAllocator::notify_spillage_of_reftyped_vlr`, has been added for that purpose. This was found by Chris' regalloc-result checker and fuzzing. That is fortunate, since it would have otherwise caused an obscure GC crash which would have been hard to track down.
cfallin
added a commit
to cfallin/wasmtime
that referenced
this pull request
Jul 16, 2020
This version of regalloc.rs includes several bugfixes for reference-types support used by the new backend framework and the aarch64 backend (bytecodealliance/regalloc.rs#85 and bytecodealliance/regalloc.rs#86).
cfallin
added a commit
to cfallin/wasmtime
that referenced
this pull request
Jul 16, 2020
This version of regalloc.rs includes several bugfixes for reference-types support used by the new backend framework and the aarch64 backend (bytecodealliance/regalloc.rs#85 and bytecodealliance/regalloc.rs#86).
cfallin
added a commit
to cfallin/regalloc.rs
that referenced
this pull request
Jul 16, 2020
…isters. This exposed an interesting fuzzbug related to dead spillslots being named in stackmaps, which was fixed in PR bytecodealliance#86; the test case is included here rather than in bytecodealliance#86 (because it needs the test-framework reftypes/safepoints parsing support added 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 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.
…ue` only when we know that
a reftyped
VirtualRangeis going to be spilled. This fixes a conceptual error in stackmapgeneration found by Chris via fuzzing. The error was that
RangeFragAndRefness::is_refwaspreviously set to
truetoo early. Specifically, spill slots for allVirtualRangesof avirtual range equivalence class are allocated at the point where the first
VirtualRangein theeclass was spilled. And the
RangeFragAndRefness::is_refof allRangeFrags owned by theeclass was set to
trueif theVirtualRangewas reftyped.From the point of view of "does this spill slot fragment carry a reftyped thing, or not?",
that's exactly correct. However, it ignores the fact that other
VirtualRanges in the sameeclass ultimately might not be spilled. Hence the effect is to potentially mark some of those
spill slot sections as reftyped even though they will never be used. Consequently the client
could end up passing such slot sections to its GC for scavenging etc even though they contain
undefined values. This could cause crashing or worse.
The fix is (conceptually) very simple: don't set
RangeFragAndRefness::is_reftotruewheninitially allocating spill slots. Instead, set it (them) later in the process, when spilling a
VirtualRangethat is reftyped. A new method,SpillSlotAllocator::notify_spillage_of_reftyped_vlr, has been added for that purpose.This was found by Chris' regalloc-result checker and fuzzing. That is fortunate, since it would
have otherwise caused an obscure GC crash which would have been hard to track down.