khagankhan opened PR #12996 from khagankhan:gc-cast to bytecodealliance:main:
Summary
Add support for reference casting and testing in the GC fuzzer.
- Upcasts from a subtype to a supertype, emitted as
ref.cast.- Fallible downcasts from a supertype to a subtype, lowered in a non-trapping form using
ref.test,ref.cast, andref.null.- Skipped
br_on_cast_failandbr_on_cast(We will have these later).Fixup preserves the operand already on the stack:
- For upcasts, it keeps the subtype fixed and repairs the supertype if needed.
- For downcasts, it keeps the supertype fixed and repairs the subtype if needed.
Fixup repairs casts in three cases:
- If the existing
sub <: superrelation is already valid, it keeps the cast unchanged.- If the relation is invalid but a direct related type exists, it repairs the cast to use that direct supertype or subtype.
- If no related type can be found, it falls back to a self-cast.
Downcasts are emitted in a trap-free form like:
... local.tee 7 ref.test (ref null 5) if (result (ref null 5)) local.get 7 ref.cast (ref null 5) else ref.null 5 end ...New tests have been added to test the new features.
+cc @fitzgen @eeide
khagankhan requested fitzgen for a review on PR #12996.
khagankhan requested wasmtime-fuzz-reviewers for a review on PR #12996.
github-actions[bot] added the label fuzzing on PR #12996.
github-actions[bot] commented on PR #12996:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
khagankhan commented on PR #12996:
The the bug I mentioned turns out be false positive. I was running standalone version of the fuzzer
khagankhan edited a comment on PR #12996:
The the bug I mentioned turns out to be false positive. I was running standalone version of the fuzzer
fitzgen submitted PR review:
LGTM, let me know when you diagnose+fix the trap you saw locally, or if you need another set of eyes on it
khagankhan commented on PR #12996:
Thanks! @fitzgen that bug was not from this PR but on local which has more features. I think this is good to be merged after ~1 hour of fuzzing with no crashes
fitzgen submitted PR review.
fitzgen added PR #12996 gc_fuzz: Add support for casting and testing references to the merge queue.
fitzgen removed PR #12996 gc_fuzz: Add support for casting and testing references from the merge queue.
fitzgen merged PR #12996.
Last updated: Apr 12 2026 at 23:10 UTC