jrandolf opened PR #14835 from jrandolf:map-lift-validate-before-alloc to bytecodealliance:main:
Lifting a
map<K, V>into aHashMapreserved capacity for the guest-supplied length before checking that the entries actually fit in linear memory. This moves the allocation after the bounds, alignment and fuel checks, the same order lists use.For reference, before this change a guest with a single page of memory returning
(ptr = 0, len = u32::MAX)for amap<u32, u32>made the host's peak RSS jump by about 8 GiB (hashbrown initializes its control bytes) before the call failed with the bounds error. The added test checks for that error; I couldn't find a non-flaky way to assert on the allocation itself, but I'm happy to add one if there's a preferred pattern.Closes #14810
jrandolf has marked PR #14835 as ready for review.
jrandolf removed the review request for wasmtime-core-reviewers from PR #14835.
jrandolf requested wasmtime-core-reviewers for a review on PR #14835.
jrandolf requested pchickey for a review on PR #14835.
github-actions[bot] added the label wasmtime:api on PR #14835.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
I don't think this test is actually testing anything -- this passes before the change right?
:speech_balloon: alexcrichton created PR review comment:
It's ok to drop this comment, this is more of a commentary on "code as it was" which is irrelevant when this PR lands
alexcrichton removed the review request for pchickey from PR #14835.
jrandolf updated PR #14835.
:memo: jrandolf submitted PR review.
:speech_balloon: jrandolf created PR review comment:
Yes, removed.
:memo: jrandolf submitted PR review.
:speech_balloon: jrandolf created PR review comment:
Done
jrandolf edited PR #14835:
Lifting a
map<K, V>into aHashMapreserved capacity for the guest-supplied length before checking that the entries actually fit in linear memory. This moves the allocation after the bounds, alignment and fuel checks, the same order lists use.For reference, before this change a guest with a single page of memory returning
(ptr = 0, len = u32::MAX)for amap<u32, u32>made the host's peak RSS jump by about 8 GiB (hashbrown initializes its control bytes) before the call failed with the bounds error. The call failed with the bounds error both before and after this change, so there's no test here; the allocation itself isn't observable from the test suite.Closes #14810
jrandolf requested alexcrichton for a review on PR #14835.
:thumbs_up: alexcrichton submitted PR review.
alexcrichton added PR #14835 Validate map pointer/length before allocating when lifting to the merge queue.
:check: alexcrichton merged PR #14835.
alexcrichton removed PR #14835 Validate map pointer/length before allocating when lifting from the merge queue.
Last updated: Oct 31 2026 at 23:03 UTC