DavidMazarro / wasm-verify

A proof-of-concept formal verification tool for WebAssembly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for deferred error reporting in VerifiWASM monad

DavidMazarro opened this issue · comments

The VerifiWASM monad currently has two error reporting functions available: logError, which adds an error to the VerifiWASM error log, and failWithError, which does that an in addition throws an exception exiting further computations. Currently, all possible errors in VerifiWASM are using the failWithError function. This means that only one error at a time will be showed to the user.

Some of the errors that happen during the analysis of a VerifiWASM specification would not require the tool to exit instantly, and could instead be deferred until a fatal error is found later, logging all of the errors found up to that point. This includes many of the validation errors in the VerifiWASM.Validation module.

The main challenge to implement deferred error reporting is figuring out how to eventually throw an error into the VerifiWASM monad. It does not suffice to replace some of the non-fatal calls to failWithError with calls to logError since logError does not throw an error (it only logs them); so, for example, if we encounter some non-fatal errors (calls to logError) during the validation phase, but we proceed with the execution, unexpected runtime errors in the posterior phases could arise since wasm-verify did not exit the execution and assumes that the validations held for the rest of the phases.

One potential way to do this would be to add an accumulator of errors and check it at the end of each phases: if there was some error, we log all of the errors and exit the program without proceeding with the posterior phases.

Looks like the validation-selective library might be of some help here.