Skip to content

Conversation

@aheejin
Copy link
Member

@aheejin aheejin commented Dec 6, 2021

When a wasm exception is thrown and uncaught in the interpreter, it
caused the whole interpreter to crash, rather than gracefully reporting
it. This fixes the problem, and also compares whether an uncaught
exception happened when comparing the results before and after
optimizations in --fuzz-exec. To do that, when --fuzz-exec is given,
we now compare results even when the function does not have return
values. Logs for some existing test have changed because of this.

When a wasm exception is thrown and uncaught in the interpreter, it
caused the whole interpreter to crash, rather than gracefully reporting
it. This fixes the problem, and also compares whether an uncaught
exception happened when comparing the results before and after
optimizations in `--fuzz-exec`. To do that, when `--fuzz-exec` is given,
we now compare results even when the function does not have return
values. Logs for some existing test have changed because of this.
@aheejin aheejin requested a review from kripken December 6, 2021 22:20
} else {
std::cout << ret << '\n';
}
FunctionResult ret = run(func, wasm, instance);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is mostly indentation changes due to the removal of if

@aheejin
Copy link
Member Author

aheejin commented Dec 6, 2021

When comparing results, now we compare exceptions. Should we compare whether a trap has occurred too? I think this can depend on some trap-related options, so if we do that, it'd better be done as a followup.

return {};
} catch (const WasmException& e) {
std::cout << "[exception thrown: " << e << "]" << std::endl;
return {{}, true};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate from this PR, I like this idea of tracking an exception, and I think maybe we should track traps too. That is, we could have an enum "normal, exception, trap", and then line 242 would mark "trap" like this line would mark "exception".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind if I change to that in a followup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, followup sounds better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #4405.

@aheejin aheejin merged commit f0d8351 into WebAssembly:main Dec 7, 2021
@aheejin aheejin deleted the interpreter_uncaught_ex branch December 7, 2021 01:12
aheejin added a commit to aheejin/binaryen that referenced this pull request Dec 21, 2021
We used to only compare return values, and in WebAssembly#4369 we started comparing
whether an uncaught exception was thrown. This also adds whether a trap
occurred to `ExecutionResults`. So in `--fuzz-exec`, if a program with a
trap loses the trap or vice versa, it will error out saying the result
has changed, unless either of `--ignore-implicit-traps` or
`--trans-never-happen` is set.
aheejin added a commit to aheejin/binaryen that referenced this pull request Dec 23, 2021
We used to only compare return values, and in WebAssembly#4369 we started comparing
whether an uncaught exception was thrown. This also adds whether a trap
occurred to `ExecutionResults`. So in `--fuzz-exec`, if a program with a
trap loses the trap or vice versa, it will error out saying the result
has changed, unless either of `--ignore-implicit-traps` or
`--trans-never-happen` is set.
aheejin added a commit that referenced this pull request Dec 30, 2021
We used to only compare return values, and in #4369 we started comparing
whether an uncaught exception was thrown. This also adds whether a trap
occurred to `ExecutionResults`. So in `--fuzz-exec`, if a program with a
trap loses the trap or vice versa, it will error out saying the result
has changed, unless either of `--ignore-implicit-traps` or
`--trans-never-happen` is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants