Skip to content

Add OOM test for component Func::call_async#13017

Open
fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
fitzgen:handle-oom-in-component-func-call-async
Open

Add OOM test for component Func::call_async#13017
fitzgen wants to merge 1 commit intobytecodealliance:mainfrom
fitzgen:handle-oom-in-component-func-call-async

Conversation

@fitzgen
Copy link
Copy Markdown
Member

@fitzgen fitzgen commented Apr 9, 2026

Add NameMap::get_by_str to avoid infallible String allocation in
component export name lookups. The NameMapNoIntern implementation
allocated a String on every lookup; the new method uses borrowed
&str keys directly on the underlying IndexMap instead.

Depends on #12993

@fitzgen fitzgen requested review from a team as code owners April 9, 2026 19:04
@fitzgen fitzgen requested review from alexcrichton and removed request for a team April 9, 2026 19:04
Add NameMap::get_by_str to avoid infallible String allocation in
component export name lookups. The NameMapNoIntern implementation
allocated a String on every lookup; the new method uses borrowed
&str keys directly on the underlying IndexMap instead.
@fitzgen fitzgen force-pushed the handle-oom-in-component-func-call-async branch from ac21e79 to f4fda42 Compare April 9, 2026 20:17
Comment on lines +143 to +156
impl<V> NameMap<String, V> {
/// Like [`NameMap::get`] but specialized for `String` keys to avoid
/// allocating a `String` for the lookup by using borrowed `&str` keys
/// directly on the underlying `IndexMap`.
pub fn get_by_str(&self, name: &str) -> Option<&V> {
let candidate = self.definitions.get(name);
if let Some(def) = candidate {
return Some(def);
}
let (alternate_name, _version) = alternate_lookup_key(name)?;
let (exact_key, _version) = self.alternate_lookups.get(alternate_name)?;
self.definitions.get(exact_key.as_str())
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how subtle this is I'd prefer to not duplicate the get method above. Would it be possible to refactor the trait methods or un-generalize the NameMap in general if the full generic K type parameter isn't needed?

@github-actions github-actions bot added fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Subscribe to Label Action

cc @fitzgen

Details This issue or pull request has been labeled: "fuzzing", "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

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

Labels

fuzzing Issues related to our fuzzing infrastructure wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants