wasmerio/wasmer

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

Opened this issue · 2 comments

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?

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

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.