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

unreachable error and stack trace if compiled and extra memory, not otherwise #2215

Closed
mark-pictor-csec opened this issue May 24, 2024 · 4 comments · Fixed by #2216
Closed
Labels
bug Something isn't working

Comments

@mark-pictor-csec
Copy link

mark-pictor-csec commented May 24, 2024

Describe the bug
Follow-on to #2205 . This is the original bug; in 2205, I was trying to repro this with code I could share. I've given up on that, and this just has the (proprietary) wasm blob.

See workflow run, step 7

Calling init() in the wasm results in an unreachable error and a stack trace, provided

  • extra memory is allocated, and
  • mode is compilation, not interpretation

If either of those is false the function returns without error (see preceding two steps in the worflow run).

To Reproduce

Clone the repo and run the commands listed in the README.
Alternately, run the github workflow. @ncruces and @mathetake I believe you'll have sufficient rights to do so, and I could add other wazero contributors if desired.

Expected behavior
init() runs successfully, even compiled mode + extra memory

Screenshots
N/A

Environment (please complete the relevant information):

  • Go version: 1.22.0
  • wazero Version: 1.7.2
  • Host architecture: amd64
  • Runtime mode: compiler
    • bug not hit in interpreter mode
  • Instance memory expanded to 8 MB
    • other amounts untested, but bug not hit with default mem amount

Additional context
Unfortunately I cannot provide source for the wasm binary.

I tried to copy out the source relevant to the stack trace but wasn't getting the error. It seems that either I missed something, or the code rustc produces is influenced by things that don't show up in the stack trace.

@mark-pictor-csec mark-pictor-csec added the bug Something isn't working label May 24, 2024
@mathetake
Copy link
Member

sorry, it's impossible to debug without having the code. Feel free to reopen until you got it.

@mathetake
Copy link
Member

mathetake commented May 26, 2024

one thing is that you SHOULD NOT grow the memory by yourself, it's one way to destroy the language runtime (this case Rust's allocator). The runtime is NOT aware of the growth, so anything can happen.

Edited: ^^ applies when you grow the memory during the execution, so irrelevant to your case after I quickly looked at your code.

@mathetake
Copy link
Member

sorry, I think I found some regression in the optimizing compiler around api.Memory.Grow invoked by users. Will take care of this

@mathetake mathetake reopened this May 27, 2024
mathetake added a commit that referenced this issue May 27, 2024
Since the introduction of optimizing compiler, the Memory.Grow by the users,
which has the different call path than memory.grow instruction, didn't propagate
the growth result onto compiler's ModuleInstance.

Fixes #2215

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mark-pictor-csec
Copy link
Author

Awesome, this fixes the issue I'd hit.
TYVM!
🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants