-
Notifications
You must be signed in to change notification settings - Fork 161
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
data structure passed through InstanceContext isn't preserved #135
Comments
This is due to the issue described in my comment here most likely: |
@AdamSLevy thanks for pointing that out! I'll take a look and see if I can fix it edit: hm, maybe I am missing something, but it looks like |
It's possible I'm mistaken. Apologies for a red herring. |
no worries! I'll continue to investigate in the meantime. |
@Hywan hey, any updates on the status of this issue? let me know if I can help speed this up in any way. |
Sorry, the entire team is busy on a giant secret project. I'll get back to you very soon! Thank you for your patience :-). |
@Hywan ping on this for next work :) |
|
Describe the bug
Hey, I'm currently using wasmer in gossamer. In our usage of wasmer, we pass in a
Ctx
struct as theInstanceContext
here. We instantiate the module here. TheStorage
field in the struct has an underlying trie data structure. (relevant code is here and here) The instance imports various go functions here that useStorage
to manipulate the trie key-values.I've noticed that between calls to the imported functions, the trie values become incorrect (I've verified this isn't an issue with the actual trie structure by replicating the key-values that are being inserted) I first noticed this using the substrate runtime. I created a small test wasm program to isolate this here. It first calls the external function
ext_set_storage
setting a key-value pair in the trie. Then, it calls another external functionext_twox_128
which simply hashes some value and returns it. In between these two calls, the value stored in the trie atkey
changes.Steps to reproduce
this will download the test wasm file and call the
mock_execute_block
function that performs the above, in the logs you can see the external function call logs and the trie contents:after the first call, the key
4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d
has value00000000
which is correct. then, after the second call, the value is now08007500
.Expected behavior
the values stored in the trie stay the same
Actual behavior
the values changed
Additional context
let me know if you need any more info - I've tried to isolate the issue, but please let me know if you need me to extract it more. I suspect the issue is something to do with the underlying memory being overwritten or some pointers getting mangled, but I'm not totally sure. maybe there's something I'm missing in the usage of
InstanceContext
. any help would be much appreciated!The text was updated successfully, but these errors were encountered: