Skip to content

Conversation

@lisenokdonbassenok
Copy link

Cause: wasmtime_environ::collections::EntitySet::insert called try_ensure_capacity(k.index()), while CompoundBitSet::try_ensure_capacity guarantees capacity only for indices < n. This could leave the backing bitset without space for k.index() and force a later infallible ensure_capacity inside insert, breaking the fallible-allocation contract and potentially panicking on OOM.
Summary: Update EntitySet::insert to reserve capacity for indices 0..=k.index() by calling try_ensure_capacity(k.index() + 1) so that all allocations during insertion go through the fallible path and correctly report OutOfMemory instead of panicking.

@lisenokdonbassenok lisenokdonbassenok requested a review from a team as a code owner January 30, 2026 09:02
@lisenokdonbassenok lisenokdonbassenok requested review from pchickey and removed request for a team January 30, 2026 09:02
@pchickey pchickey requested review from fitzgen and removed request for pchickey January 30, 2026 17:33
@alexcrichton
Copy link
Member

Thanks! Could you add a test for this in this file? Ideally that'd be verified to fail before this PR but then pass after this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants