Incorrect validation of ref.as_non_null in dead code
Categories
(Core :: JavaScript: WebAssembly, defect, P3)
Tracking
()
People
(Reporter: rhunt, Unassigned)
References
Details
Attachments
(1 external file)
See this issue for details. What we do is safe, but just not spec compliant.
| Reporter | ||
Updated•1 month ago
|
Comment 1•1 month ago
|
||
In unreachable code, ref.as_non_null, br_on_null and br_on_non_null pushed the fully polymorphic Bottom type when their operand was Bottom. Per the spec the result is (ref bot), which matches any reference type but no non-reference type. So we wrongly accepted modules like unreachable ref.as_non_null local.set $i32 (WebAssembly/spec#2235).
This adds a BottomRef StackType: the TypeCode::Limit sentinel with the nullable bit set. It still counts as isStackBottom(), so existing bottom handling is unchanged. popWithType and checkTopTypeMatches now go through a new checkIsSubtypeOf(StackType, ValType), which rejects BottomRef against non-reference types. isValidForUntypedSelect rejects BottomRef. The three instructions push asNonNullableStackType(), which maps Bottom to BottomRef.
Description
•