Files
wasmtime/crates
Alex Crichton b62fe21914 Update memfd image construction to avoid excessively large images (#3819)
* Update memfd image construction to avoid excessively large images

Previously memfd-based image construction had a hard limit of a 1GB
memory image but this mean that tiny wasm modules could allocate up to
1GB of memory which became a bit excessive especially in terms of memory
usage during fuzzing. To fix this the conversion to a static memory
image has been updated to first do a conversion to paged memory
initialization, which is sparse, followed by a second conversion to
static memory initialization.

The sparse construction for the paged step should make it such that the
upper/lower bounds of the initialization image are easily computed, and
then afterwards this limit can be checked against some heuristics to
determine if we're willing to commit to building up a whole static image
for that module. The heuristics have been tweaked from "must be less
than 1GB" to one of two conditions must be true:

* Either the total memory image size is at most twice the size of the
  original paged data itself.

* Otherwise the memory image size must be smaller than a reasonable
  threshold, currently 1MB.

We'll likely need to tweak this over time and it's still possible to
cause a lot of extra memory consumption, but for now this should be
enough to appease the fuzzers.

Closes #3815

* Review comments
2022-02-17 10:37:17 -06:00
..
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00
2022-02-07 19:16:26 -06:00