ref-fvm icon indicating copy to clipboard operation
ref-fvm copied to clipboard

sdk: set a panic handler to pipe extra info

Open raulk opened this issue 3 years ago • 1 comments

Context

Right now, eventual actor panics raise a Wasm trap which is caught by the invocation container (find description of logic here) and converted to an aborto with exit code SysErrActorPanic at the FVM level.

Proposal

Having the SDK set a panic handler would allow us to pipe extra information to the client, presumably for logging purposes. The panic handler could then abort with SysErrActorPanic and record the backtrace in the log file for later inspection. The node would only actually handle the backtrace if debug mode is enabled (which we would do when, e.g. getting execution traces). This is to avoid actor-driven spamming of log files.

Something to consider is whether we want to charge for the message being sent through. Probably not because the actor would've already incurred memory expansion cost to create that message. And enabling debug is an explicit opt-in user action that should come with big warning labels.

Obviously, there is no guarantee that user-deployed actor will use the SDK, so this issue doesn't imply the removal of panic handling logic at the FVM level.

raulk avatar Mar 11 '22 20:03 raulk

We currently catch panics inside the bultin-actors, and turn them into USR_ASSERTION_FAILED exit codes (sending the panic message to the kernel via the abort call). But this functionality lives in the builtin-actors runtime, not the sdk.

Stebalien avatar May 17 '22 17:05 Stebalien

Fixed in https://github.com/filecoin-project/ref-fvm/pull/896

Stebalien avatar Oct 07 '22 15:10 Stebalien