Repository navigation
Specify maximum static size for component value types - #688
Conversation
Require resolved type AST nodes to satisfy elem_size <= 2^28 - 1 for both i32 and i64 pointer types using overflow-safe validation, closing fixed-length-list sizing hazards (WebAssembly#682). Signed-off-by: Gaurav Chaudhary <[email protected]>
Apply despecialize at each recursive check_resolved_type_size call so nested map/option/record nodes are validated, not only top-level types. Add regression tests for option<map<...>> and record fields (WebAssembly#682). Signed-off-by: Gaurav Chaudhary <[email protected]>
|
Thanks for working on this! To resolve #682, I had been thinking that perhaps we could reuse the |
Replace the duplicate checked_* Python with one Element Size invariant (every despecialized AST node, both pointer widths) and short pointers in Binary, Explainer, and canonopt validation. Keep WAST coverage and drop the run_tests.py validator tests. Signed-off-by: Gaurav Chaudhary <[email protected]>
|
@lukewagner Thanks for the feedback Validation now reuses the existing elem_size definition instead of adding a separate checked_* algorithm. The full rule is in Element Size in CanonicalABI.md (every despecialized AST node, both i32 and i64), with short pointers in Explainer.md, Binary.md, and canonopt validation. WAST tests cover the edge cases; nyi.txt until wasm-tools/Wasmtime implement the validator. @alexcrichton please review this PR and give your feedback , thanks |
|
This seems fine by me modulo precise spec text yeah, it's what I was imagining on #682 at a high level |
lukewagner
left a comment
There was a problem hiding this comment.
Overall looks good to me; thanks! A few requested changes and then I expect it'll be good to go.
Use Luke's i64 Element Size validation notes and fold valid WAST types into one component with boundary compound cases. Signed-off-by: Gaurav Chaudhary <[email protected]>
|
@lukewagner & @alexcrichton Thank you so much for the review . |
Signed-off-by: Gaurav Chaudhary <[email protected]>
|
@lukewagner I have wrapped the Binary.md validation bullet as requested. |
This commit is an implementation of WebAssembly/component-model#688 where the in-memory size of component model types is now calculated and validated to be below the static threshold. The eventual goal of this implementation is to simplify logic in Wasmtime for example and reduce the affect/possibility of integer overflow when handling otherwise very large types. The limits here are large enough that all preexisting components are expected to continue to validate.
This commit is an implementation of WebAssembly/component-model#688 where the in-memory size of component model types is now calculated and validated to be below the static threshold. The eventual goal of this implementation is to simplify logic in Wasmtime for example and reduce the affect/possibility of integer overflow when handling otherwise very large types. The limits here are large enough that all preexisting components are expected to continue to validate.
Fixes #682
Summary
Adds a spec-defined maximum static value size of
2^28 - 1bytes for Component Model value types.Validation now:
i32andi64pointer types;Includes Python and WAST regression tests for fixed-length lists, compound types, nested maps, pointer-width differences, and integer-overflow cases.
The WAST test remains in
nyi.txtuntil wasm-tools/Wasmtime implement the corresponding validator rule.