alexcrichton commented on issue #2532:
I believe this can be done with
ResourceLimiter
nowadays, so closing.
alexcrichton closed issue #2532:
<!-- Please try to describe precisely what you would like to do in
Cranelift/Wasmtime and/or expect from it. You can answer the questions below if
they're relevant and delete this text before submitting. Thanks for opening an
issue! -->Feature
<!-- What is the feature or code improvement you would like to do in
Cranelift/Wasmtime? -->The ability to force-cap (exported) memories.
Benefit
<!-- What is the value of adding this in Cranelift/Wasmtime? -->
You can't cap at runtime the exported memories from emscripten. You can tell emscripten to import memory instead. WASI doesn't work with imported memory. (arguably this is an emscripten problem but WASI states memories are to be exported, not imported. so if the whole idea of importing memories goes against WASI anyway, why do it that way? being able to cap exported memories would be WASI-compliant on the other hand.)
Implementation
<!-- Do you have an implementation plan, and/or ideas for data structures or
algorithms to use? -->Just let one be able to set the Memory max to a smaller value, as long as it's no smaller than the current Memory size.
Alternatives
<!-- Have you considered alternative implementations? If so, how are they
better or worse than your proposal? -->Alternatives:
Have WASI use a provided memory instead of automatically detecting exported memory.
Breaking API change. Kind of a pain/unusable if WASI is needed by initializers.
Have WASI use a provided module name instead of automatically detecting exported memory.
Breaking API change, but would work with initializers.
Make emscripten re-export the memory.
While it should probably do this... eh, this isn't the emscripten repo.
Allow fudging modules' exports.
Being able to inject exports into a module and have those exports available through the Caller thing feels more like a gross hack than anything...
The only general-purpose solution is this proposal. Whether you have memory imports or exports, this proposal is always guaranteed to work, whereas the alternatives require a lot more cooperation from the wasm module (as they'd have to import memory instead of following WASI spec and exporting it).
Last updated: Dec 23 2024 at 12:05 UTC