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
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marine-rs-sdk"
version = "0.6.15" # remember to update html_root_url
version = "0.7.0" # remember to update html_root_url
description = "Fluence backend SDK for developing backend applications for the Fluence network"
documentation = "https://docs.rs/fluence"
repository = "https://github.com/fluencelabs/marine-rs-sdk"
Expand All @@ -18,9 +18,9 @@ path = "src/lib.rs"
doctest = false

[dependencies]
marine-macro = { path = "crates/marine-macro", version = "=0.6.15" }
marine-rs-sdk-main = { path = "crates/main", version = "=0.6.15" }
marine-timestamp-macro = { path = "crates/timestamp-macro", version = "=0.6.15" }
marine-macro = { path = "crates/marine-macro", version = "=0.7.0" }
marine-rs-sdk-main = { path = "crates/main", version = "=0.7.0" }
marine-timestamp-macro = { path = "crates/timestamp-macro", version = "=0.7.0" }
polyplets = "0.2.0"

serde = { version = "1.0.118", features = ["derive"]}
Expand Down
2 changes: 1 addition & 1 deletion crates/main/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marine-rs-sdk-main"
version = "0.6.15" # remember to update html_root_url
version = "0.7.0" # remember to update html_root_url
edition = "2018"
description = "Contains logger, allocators and several other modules for marine-rs-sdk"
documentation = "https://docs.rs/marine-rs-sdk-main"
Expand Down
2 changes: 1 addition & 1 deletion crates/main/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#![allow(clippy::missing_safety_doc)]
#![allow(clippy::needless_doctest_main)]
#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.6.15")]
#![doc(html_root_url = "https://docs.rs/marine-rs-sdk-main/0.7.0")]
#![deny(
dead_code,
nonstandard_style,
Expand Down
2 changes: 1 addition & 1 deletion crates/marine-macro-impl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marine-macro-impl"
version = "0.6.15" # remember to update html_root_url
version = "0.7.0" # remember to update html_root_url
edition = "2018"
description = "Implementation of the `#[marine]` macro"
documentation = "https://docs.rs/fluence/marine-macro-impl"
Expand Down
2 changes: 1 addition & 1 deletion crates/marine-macro-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.6.15")]
#![doc(html_root_url = "https://docs.rs/marine-macro-impl/0.7.0")]
#![deny(
dead_code,
nonstandard_style,
Expand Down
6 changes: 3 additions & 3 deletions crates/marine-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marine-macro"
version = "0.6.15" # remember to update html_root_url
version = "0.7.0" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[marine]` macro"
documentation = "https://docs.rs/fluence/marine-macro"
Expand All @@ -18,5 +18,5 @@ proc-macro = true
doctest = false

[dependencies]
marine-macro-impl = { path = "../marine-macro-impl", version = "=0.6.15" }
marine-rs-sdk-main = { path = "../main", version = "=0.6.15" }
marine-macro-impl = { path = "../marine-macro-impl", version = "=0.7.0" }
marine-rs-sdk-main = { path = "../main", version = "=0.7.0" }
2 changes: 1 addition & 1 deletion crates/marine-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//!
//! ```

#![doc(html_root_url = "https://docs.rs/marine-macro/0.6.15")]
#![doc(html_root_url = "https://docs.rs/marine-macro/0.7.0")]
#![deny(
dead_code,
nonstandard_style,
Expand Down
2 changes: 1 addition & 1 deletion crates/timestamp-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "marine-timestamp-macro"
version = "0.6.15" # remember to update html_root_url
version = "0.7.0" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[build_timestamp]` macro"
documentation = "https://docs.rs/fluence/marine-timestamp-macro"
Expand Down
22 changes: 21 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//! pub fn curl_get(url: String) -> String;
//! }
//! ```
#![doc(html_root_url = "https://docs.rs/sdk/0.6.15")]
#![doc(html_root_url = "https://docs.rs/sdk/0.7.0")]
#![deny(
dead_code,
nonstandard_style,
Expand Down Expand Up @@ -103,3 +103,23 @@ pub mod internal {
pub use marine_rs_sdk_main::add_object_to_release;
pub use marine_timestamp_macro::build_timestamp;
}

// Adds an explicit __wasm_call_ctors call to tell LLVM not to
// wrap every export in __wasm_call_ctors/__wasm_call_dtors calls.
// The most referenced issue about it is https://github.com/WebAssembly/WASI/issues/471
ValeryAntopol marked this conversation as resolved.
Show resolved Hide resolved
/// For internal use. Not an API function.
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
extern "C" {
fn __wasm_call_ctors();
}

/// For internal use. Not an API function.
#[cfg(target_arch = "wasm32")]
#[doc(hidden)]
#[no_mangle]
pub fn _initialize() {
unsafe {
__wasm_call_ctors();
}
}
10 changes: 5 additions & 5 deletions tests/compilation_tests/export_functions/array_inner_refs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ error: a vector type in arguments of export functions shouldn't contain referenc
--> $DIR/array_inner_refs.rs:13:23
|
13 | pub fn inner_arrays_1(_arg: Vec<&Vec<Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^

error: a vector type in arguments of export functions shouldn't contain references
--> $DIR/array_inner_refs.rs:18:23
|
18 | pub fn inner_arrays_2(_arg: Vec<Vec<&Vec<Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^

error: a vector type in arguments of export functions shouldn't contain references
--> $DIR/array_inner_refs.rs:23:23
|
23 | pub fn inner_arrays_3(_arg: Vec<Vec<Vec<&Vec<u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^

error: a vector type in arguments of export functions shouldn't contain references
--> $DIR/array_inner_refs.rs:28:23
|
28 | pub fn inner_arrays_4(_arg: Vec<Vec<Vec<Vec<&u8>>>>) -> Vec<Vec<Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^

error: a vector type in arguments of export functions shouldn't contain references
--> $DIR/array_inner_refs.rs:33:35
|
33 | pub fn inner_arrays_5(_arg1: i32, _arg2: Vec<Vec<Vec<&Vec<u8>>>>, _arg3: i32) -> Vec<Vec<Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ error: types with lifetimes or generics aren't allowed
--> $DIR/improper_types.rs:8:17
|
8 | fn test(_arg_1: Box<i32>) {}
| ^^^^^^^^
| ^^^

error: types with lifetimes or generics aren't allowed
--> $DIR/improper_types.rs:11:27
|
11 | fn test2(_arg_1: std::rc::Rc<i32>) {}
| ^^^^^^^
| ^^

error: types with lifetimes or generics aren't allowed
--> $DIR/improper_types.rs:14:36
|
14 | fn test3(_arg_1: std::collections::HashMap<i32, String>) {}
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^

error: Incorrect argument type, only path or reference are available on this position
--> $DIR/improper_types.rs:17:26
Expand All @@ -26,4 +26,4 @@ error: types with lifetimes or generics aren't allowed
--> $DIR/improper_types.rs:22:26
|
22 | fn test5(_arg_1: i32) -> Box<i32> {
| ^^^^^^^^
| ^^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ error: a vector type in output types of export functions shouldn't contain refer
--> $DIR/inner_vec_refs.rs:8:54
|
8 | pub fn inner_arrays_2(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<Vec<&Vec<Vec<u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^

error: a vector type in output types of export functions shouldn't contain references
--> $DIR/inner_vec_refs.rs:13:54
|
13 | pub fn inner_arrays_3(_arg: &Vec<Vec<Vec<Vec<u8>>>>) -> &Vec<&Vec<&Vec<&Vec<&u8>>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
error: import function can't return a value with references
--> $DIR/arrays_out_inner_refs.rs:10:5
|
10 | / #[marine]
11 | | pub fn func_1() -> &String;
| |_______________________________^
10 | #[marine]
| ^
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: types with lifetimes or generics aren't allowed
--> $DIR/improper_types.rs:11:21
|
11 | fn test(_arg_1: Box<i32>);
| ^^^^^^^^
| ^^^
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ error: types with lifetimes or generics aren't allowed
--> $DIR/struct_with_improper_types.rs:7:12
|
7 | pub a: Box<i32>,
| ^^^^^^^^
| ^^^

error: types with lifetimes or generics aren't allowed
--> $DIR/struct_with_improper_types.rs:12:21
|
12 | pub a: std::rc::Rc<i32>,
| ^^^^^^^
| ^^

error: types with lifetimes or generics aren't allowed
--> $DIR/struct_with_improper_types.rs:17:30
|
17 | pub a: std::collections::HashMap<i32, String>,
| ^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^
2 changes: 1 addition & 1 deletion tests/compilation_tests/records/unnamed_structs.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ error: only named fields are allowed in structs
--> $DIR/unnamed_structs.rs:8:1
|
8 | struct A(pub i32, pub u32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^