bytecodealliance / bytecodealliance/ComponentizeJS

Import return buffers are never freed

Open
#330 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
391
Forks
53
Avg merge
3d 5h
Merged PRs (30d)
1

Description

**Issue details assume #319 is merged.**

Import return buffers allocated via `cabi_realloc` in the splicer are never freed. The old `free_list` bulk free in `post_call` was the only mechanism reclaiming them, but it also caused use-after-free (#224, fixed by #319).

The retptr is returned to JS as a pointer, and JS reads from it after the WASM glue returns, so there's no obvious place to insert a free in the current architecture. This is an unbounded leak for components that make repeated import calls returning strings or lists.

Separately, I noticed the bindgen sets `post_return: None` so ComponentizeJS never generates post-return functions for exports. The canonical ABI expects the host to call post-return so the guest can free export return buffers. I haven't investigated whether `post_call` covers this already.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the splicer’s `cabi_realloc` handling and the `post_call` free-list logic, with issue #319 as a prerequisite and #224 for the prior use-after-free. Then inspect the bindgen setting `post_return: None` and how ComponentizeJS handles export post-return calls. Done requires a decided ownership and reclamation design that prevents both leaks and use-after-free.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.