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 wasm memory bug #2066

Merged
merged 8 commits into from
Apr 29, 2024
Merged

Fix wasm memory bug #2066

merged 8 commits into from
Apr 29, 2024

Conversation

Harrm
Copy link
Contributor

@Harrm Harrm commented Apr 25, 2024

Referenced issues

Description of the Change

Clang-15's TSAN doesn't work on new linux kernels.
Runtime Memory had a nasty circular dependency on a memory allocator, which is refactored here.

Possible Drawbacks

Checklist Before Opening a PR

Before you open a Pull Request (PR), please make sure you've completed the following steps and confirm by answering 'Yes' to each item:

  1. Code is formatted: Have you run your code through clang-format to ensure it adheres to the project's coding standards? Yes
  2. Code is documented: Have you added comments and documentation to your code according to the guidelines in the project's contributing guidelines? Yes
  3. Self-review: Have you reviewed your own code to ensure it is free of typos, syntax errors, logical errors, and unresolved TODOs or FIXME without linking to an issue? Yes
  4. Zombienet Tests: Have you ensured that the zombienet tests are passing? Zombienet is a network simulation and testing tool used in this project. It's important to ensure that these tests pass to maintain the stability and reliability of the project. No

@Harrm Harrm marked this pull request as ready for review April 25, 2024 16:15
@Harrm Harrm requested review from turuslan and xDimon April 25, 2024 16:15
Comment on lines +40 to +45
runtime::MemoryConfig config{kDefaultHeapBase, {}};
auto handle = std::make_shared<MemoryImpl>(rei_->getMemory(), config);
auto allocator =
std::make_unique<runtime::MemoryAllocatorImpl>(handle, config);
allocator_ = allocator.get();
memory_ = std::make_unique<runtime::Memory>(handle, std::move(allocator));
Copy link
Member

Choose a reason for hiding this comment

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

How about combine calls for Memory assemble into single free-function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but in the end it didn't seem to be very useful, as it would eliminate just a couple of simple lines of code that create allocator across the entire code base.

@@ -68,7 +85,7 @@ namespace kagome::runtime {
std::optional<uint32_t> readFree(WasmPointer ptr) const;

private:
Memory &memory_;
std::shared_ptr<MemoryHandle> memory_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rust passes Memory & to each allocate/deallocate call

@Harrm Harrm enabled auto-merge (squash) April 29, 2024 13:22
@Harrm Harrm merged commit 58d3ea6 into master Apr 29, 2024
10 of 11 checks passed
@Harrm Harrm deleted the fix/wasm-memory-circular branch April 29, 2024 13:25
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.

4 participants