-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(c-api) Call wasi_env_delete
manually
#2090
Conversation
`wasi_get_imports` isn't taking ownership of `wasi_env_t` (despites what is written in the documentation). And it must not take ownership of it, since one could use it with the `wasi_env_read_stdout` & sibling functions after having called `wasi_get_imports`. Consequently, this patch calls `wasi_env_delete` to avoid leaking memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Posted on Slack, but I think this is not symmetric with what we do in Rust and that the wasi_env_t
is invalid so it's a bit odd to require manually deleting it in my opinion
We don't take ownership of wasmer/lib/c-api/src/wasm_c_api/wasi/mod.rs Lines 536 to 542 in 3ed1e47
And we just clone the inner value: wasmer/lib/c-api/src/wasm_c_api/wasi/mod.rs Line 564 in 3ed1e47
So |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, if it works then maybe that's a feature. The docs on the wasi_env_t
type itself might need to be updated, I suspect they probably say that it does not need to be deleted.
Documentation has already been updated for |
bors r+ |
2090: fix(c-api) Call `wasi_env_delete` manually r=Hywan a=Hywan # Description `wasi_get_imports` isn't taking ownership of `wasi_env_t` (despites what is written in the documentation). And it must not take ownership of it, since one could use it with the `wasi_env_read_stdout` & sibling functions after having called `wasi_get_imports`. Consequently, this patch calls `wasi_env_delete` to avoid leaking memory. # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Ivan Enderlin <[email protected]>
Build failed: |
I believe these is something bigger happening here. cc @MarkMcCaskey |
bors r+ |
Description
wasi_get_imports
isn't taking ownership ofwasi_env_t
(despiteswhat is written in the documentation). And it must not take ownership
of it, since one could use it with the
wasi_env_read_stdout
&sibling functions after having called
wasi_get_imports
.Consequently, this patch calls
wasi_env_delete
to avoid leakingmemory.
Review