Open Bug 2078925 Opened 1 month ago Updated 1 month ago

Incorrect validation of ref.as_non_null in dead code

Categories

(Core :: JavaScript: WebAssembly, defect, P3)

defect

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.

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.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: