Skip to content
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 memory leak in compiled modules caused by rust ^1.56 #75

Merged
merged 7 commits into from
Jul 27, 2022

Conversation

ValeryAntopol
Copy link
Collaborator

No description provided.

@linear
Copy link

linear bot commented Jul 4, 2022

VM-115 Fix memory leak in marine modules built with rustc ^1.56

In rustc 1.56 updated LLVM to 13 version, which started wrapping all export function in __wasm_call_ctors and __wasm_call_dtors functions as it started building modules as Commands by default (WebAssembly/WASI#13). Other people also encountered errors because of this (WebAssembly/WASI#471)

There a two main ways to change this behaviour:

  • add an explicit call to __wasm_call_ctors
  • use -Z wasi-exec-model=reactor rustc flag (requires nightly)

Bot options require updating existing modules to new sdk in order to fix memory leak. As we dont want to switch to nightly in marine-rs-sdk, we choose the fist option.

The fix will include:

  • explicit call to __wasm_call_ctors in marine_rs_sdk::module_manifest macro
  • requirement to define a marine_initialize (or the similiar name) function in marine modules
  • warning or error in marine runtime in case of loading module built without memory leak fix. The check might be implemented by looking at embedded sdk version, or by some more accurate check without false-positive errors.

@ValeryAntopol ValeryAntopol marked this pull request as ready for review July 5, 2022 10:34
Copy link
Member

@mikevoronov mikevoronov left a comment

Choose a reason for hiding this comment

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

utACK.

Do not forget to add a feature for disabling adding ctors.

src/lib.rs Outdated Show resolved Hide resolved
@ValeryAntopol ValeryAntopol merged commit 5bc6f5e into master Jul 27, 2022
@ValeryAntopol ValeryAntopol deleted the feat/VM-115-wasm_ctors_workaround branch July 27, 2022 13:04
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