You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CryZe opened this issue
Jun 17, 2023
· 2 comments
· Fixed by #112969
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.I-memleakIssue: Runtime memory leak without `mem::forget`.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/
If you compile this to a WASI library and call the update function from a WASM runtime, then it will query the metadata of the file only during the first call to update. Every other invocation the update function should do nothing.
Instead, this happened:
The update function seems to refresh the list of preopened directories on every call... and it leaks them. The WASM memory keeps growing, looking like this:
This likely is because of the way Rust lazily initializes the list of preopened directories through wasi-libc. It probably does it unconditionally, which wasi-libc probably can't handle, so it never frees any memory.
The problem also occurs if you have any file system code at all, and it never even gets called:
workingjubilee
added
O-wasm
Target: WASM (WebAssembly), http://webassembly.org/
I-heavy
Issue: Problems and improvements with respect to binary size of generated code.
A-runtime
Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
I-memleak
Issue: Runtime memory leak without `mem::forget`.
and removed
I-heavy
Issue: Problems and improvements with respect to binary size of generated code.
labels
Jun 17, 2023
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.I-memleakIssue: Runtime memory leak without `mem::forget`.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/
I tried this code:
I expected to see this happen:
If you compile this to a WASI library and call the update function from a WASM runtime, then it will query the metadata of the file only during the first call to update. Every other invocation the update function should do nothing.
Instead, this happened:
The update function seems to refresh the list of preopened directories on every call... and it leaks them. The WASM memory keeps growing, looking like this:
This likely is because of the way Rust lazily initializes the list of preopened directories through wasi-libc. It probably does it unconditionally, which wasi-libc probably can't handle, so it never frees any memory.
The problem also occurs if you have any file system code at all, and it never even gets called:
If you compile this code, but never call
other
and instead onlyupdate
, it also keeps leaking the list of preopened directories.The WASM seems to come down to this:
with
__wasilibc_populate_preopens
looks too complex. The original C code probably needs to be checked.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: