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

c-api shows no error message when failing instantiation, how to check what is wrong? #4581

Open
MrHate opened this issue Apr 17, 2024 · 2 comments
Labels
📦 lib-c-api About wasmer-c-api ❓ question I've a question!
Milestone

Comments

@MrHate
Copy link

MrHate commented Apr 17, 2024

Summary

I was trying wasmer with c-api (static link with libwasmer.a generated from make build-capi) but kept failing instantiation. However, the only error information I got was the return value from wasm_instance_new.
I don't really realize what was actually wrong with my program, wondering if there is a way to extract some helpful information relavant to my mistake?

@MrHate MrHate added the ❓ question I've a question! label Apr 17, 2024
@syrusakbary
Copy link
Member

Would it be possible to have the program so we can investigate a bit more how we can improve the error messages?

@syrusakbary syrusakbary added the 📦 lib-c-api About wasmer-c-api label Apr 23, 2024
@MrHate
Copy link
Author

MrHate commented Apr 23, 2024

For example, I have my code using wasmer with c-api like the following:

...
instance = wasm_instance_new(store, module, &imports, NULL);
if (!instance) {
  fprintf(stderr, "Err instantiating.\n");
  goto init_fail;
}
...

If any of the Wasm application's required imports is missing during the instantiation, this code fails with a NULL return value for instance, but nothing more printed to explain the error.

To figure out what is actually wrong with my code I had to add prints to each exception handler here: https://github.com/wasmerio/wasmer/blob/master/lib/c-api/src/wasm_c_api/instance.rs#L59.

@syrusakbary syrusakbary added this to the v4.4 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 lib-c-api About wasmer-c-api ❓ question I've a question!
Projects
None yet
Development

No branches or pull requests

2 participants