Skip to content

Make error handling in the WebAssembly interpreter easier

Camil Staps requested to merge improve-error-handling into master

Various improvements to ease error handling in the WebAssembly interpreter, which is required for itasks-sdk#466 (closed):

  • Add resolve_pie_symbol which, given an address from the frontend, returns the symbol name the address is part of and the offset from that symbol to the address. This can be used in conjunction with the JavaScript API's get_trace to get a symbolic trace.
  • Add error_handler option to the JavaScript instantiate function to set an error handler for the interpreter. This error handler is then applied to all functions run in the interpreter. This is better than requiring applications to encapsulate interpret in try .. catch, because we may set callbacks from Clean and errors in these callbacks should be handled as well. The error_handler function receives both the thrown JavaScript object (from which we can get the JavaScript stack trace) and the Clean stack trace (from get_trace) which can be given to resolve_pie_symbol to get a symbolic Clean stack trace.

Note that it is not possible to get a symbolic Clean stack trace on the client alone, because the WebAssembly interpreter has no symbol table.

Edited by Camil Staps

Merge request reports