mirror of
https://github.com/fluencelabs/trust-graph
synced 2025-04-24 23:32:13 +00:00
Add memory leak temporary mitigation (#42)
This commit is contained in:
parent
b9fbbbcafb
commit
aa72fdab64
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2672,7 +2672,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "trust-graph-wasm"
|
name = "trust-graph-wasm"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bincode",
|
"bincode",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "trust-graph-wasm"
|
name = "trust-graph-wasm"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "trust graph wasm"
|
description = "trust graph wasm"
|
||||||
|
@ -13,10 +13,31 @@ mod results;
|
|||||||
mod service_api;
|
mod service_api;
|
||||||
mod storage_impl;
|
mod storage_impl;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
/*
|
||||||
|
_initialize function that calls __wasm_call_ctors is required to mitigade memory leak
|
||||||
|
that is described in https://github.com/WebAssembly/wasi-libc/issues/298
|
||||||
|
|
||||||
|
In short, without this code rust wraps every export function
|
||||||
|
with __wasm_call_ctors/__wasm_call_dtors calls. This causes memory leaks. When compiler sees
|
||||||
|
an explicit call to __wasm_call_ctors in _initialize function, it disables export wrapping.
|
||||||
|
|
||||||
|
TODO: remove when updating to marine-rs-sdk with fix
|
||||||
|
*/
|
||||||
|
extern "C" {
|
||||||
|
pub fn __wasm_call_ctors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
fn _initialize() {
|
||||||
|
unsafe {
|
||||||
|
__wasm_call_ctors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//------------------------------
|
||||||
pub static TRUSTED_TIMESTAMP: (&str, &str) = ("peer", "timestamp_sec");
|
pub static TRUSTED_TIMESTAMP: (&str, &str) = ("peer", "timestamp_sec");
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
_initialize(); // As __wasm_call_ctors still does necessary work, we call it at the start of the module
|
||||||
WasmLoggerBuilder::new()
|
WasmLoggerBuilder::new()
|
||||||
.with_log_level(log::LevelFilter::Trace)
|
.with_log_level(log::LevelFilter::Trace)
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user