-
Notifications
You must be signed in to change notification settings - Fork 689
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
bugfix: wasmtime: instantiating function type incompatibility #12096
Conversation
@akorchyn Thank you for your contribution! Your pull request is now a part of the Race of Sloths! Current status: executed
Your contribution is much appreciated with a final score of 8! Congratulations @akorchyn! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it What is the Race of SlothsRace of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow For contributors:
For maintainers:
Feel free to check our website for additional details! Bot commands
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #12096 +/- ##
==========================================
- Coverage 71.59% 71.59% -0.01%
==========================================
Files 818 818
Lines 164532 164532
Branches 164532 164532
==========================================
- Hits 117794 117789 -5
- Misses 41595 41604 +9
+ Partials 5143 5139 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@akhi3030 can you re-add to the merge queue? |
🥁 Score it! @frol, please score the PR with |
@race-of-sloths score 8 |
The fix seems reasonable. We do indeed have a problem where each individual invocation of the runtime will operate with a brand new It might make a ton of sense to re-use the same engine for everything, but since the engine holds onto things like all the types it has ever seen, that would lead to eventually unbounded memory growth. The reason why we're seeing type mismatches here is exactly because the module instance most likely references types by indices into engine somewhere... |
Thank you. However, I still feel weird about how these engines differ. As we load from cache with the engine from the State and the Module::deserialize seems to be clone Arc under the hood, so they should be the same (inside the Engine and inside the State), but it's not really true :( |
Resolves: #12062
This PR resolves the issue with the wasmtime function type incompatibility.
To understand the issue, I highly recommend my investigation comments on the issue itself: #12062
To be honest, I'm not sure it's a proper fix as I guess the root cause of the issue is somewhere outside of the file that leads to running under different engines/settings, leading to instantiating failures. It's a bit weird that the WasmtimeVM instance and Module instance could be different somehow as wasmtime::Engine is an arc wrapper. And module seems to clone it inside which should be still the same instance.
I could reproduce the issue only by tweaking the code manually by recreating an engine before the linking. It means that something more complex happens and we need a test on that
But this fix resolves an issue reported by #12062: /~https://github.com/near/near-workspaces-rs/actions/runs/10835958697/job/30200440749
CC @race-of-sloths