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

wasi Runtime error? #712

Open
orangeC23 opened this issue Apr 10, 2023 · 0 comments
Open

wasi Runtime error? #712

orangeC23 opened this issue Apr 10, 2023 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@orangeC23
Copy link

Describe the bug

Using wasmer python to execute the tmp.wasm with wasi.
The wasm file is :
tmp-wasm.txt
The python file is :

import os

from wasmer import engine, wat2wasm, Store, Module, Instance, wasi
from wasmer_compiler_cranelift import Compiler
# from wasmer_compiler_llvm import Compiler
# from wasmer_compiler_singlepass import Compiler

engine = engine.Universal(Compiler)

# Create a store, that holds the engine.
store = Store(engine)

# Let's compile the Wasm module with the Cranelift compiler.
__dir__ = os.path.dirname(os.path.realpath(__file__))
module = Module(Store(), open(__dir__ + './tmp.wasm', 'rb').read())


# Get the WASI version.
wasi_version = wasi.get_version(module, strict=True)

# Build a WASI environment for the imports.
wasi_env = wasi.StateBuilder('test-program').argument('--foo').finalize()

# Generate an `ImportObject` from the WASI environment.
import_object = wasi_env.generate_import_object(store, wasi_version)

# Now we are ready to instantiate the module.
instance = Instance(module, import_object)

# Here we go, let's start the program.
# instance.exports._start()

# Let's instantiate the Wasm module.
# instance = Instance(module)

# Let's call the `sum` exported function.
func1 = instance.exports._start
results = func1()

print(results)

Steps to reproduce

python tmp.py

Expected behavior

Print:
Hello world!
buf ptr: 0x500d88
buf: 1234

Actual behavior

Print:
Hello world!
buf ptr: 0x500d88
buf: 1234
Traceback (most recent call last):
File "wasmer-python-A5-2.py", line 38, in
results = func1()
RuntimeError: RuntimeError: WASI exited with code: 0

@orangeC23 orangeC23 added the 🐞 bug Something isn't working label Apr 10, 2023
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

No branches or pull requests

1 participant