Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception logging (win32): Handle error codes correctly, add some more strings #414

Merged
merged 3 commits into from
May 6, 2019

Conversation

hrydgard
Copy link

@hrydgard hrydgard commented May 2, 2019

Ran into a situation with an unknown exception from Cranelift (will probably report that one separately). Turns out the signum was "1" though which does not seem to correspond to any of the Windows error codes, except possibly STATUS_GUARD_PAGE which is 0x80000001, but only if we lost the top bit somewhere.

On Windows, exceptions seemed to be trapped by callProtected, which is implemented here: https://github.com/wasmerio/wasmer/blob/cade9a666f5dfedfc9352718988aa26f21b028f4/lib/win-exception-handler/exception_handling/exception_handling.c . It did not seem to correctly store and retrieve the exception code, instead always returning 1: longjmp(jmpBuf, 1);

So I fixed it. And now the log output looks like this:

unhandled trap at 1560d5e7bab - code #c0000005: segmentation violation

@syrusakbary
Copy link
Member

bors try

bors bot added a commit that referenced this pull request May 3, 2019
@bors
Copy link
Contributor

bors bot commented May 3, 2019

@bjfish bjfish requested a review from xmclark May 3, 2019 04:40
Copy link
Contributor

@xmclark xmclark left a comment

Choose a reason for hiding this comment

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

💯

@@ -74,7 +77,7 @@ uint8_t callProtected(trampoline_t trampoline,
return TRUE;
}

out_result->code = (uint64_t)signum;
out_result->code = (uint64_t)caughtExceptionCode;
Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch! Thanks for fixing this.

EXCEPTION_GUARD_PAGE => "guard page",
EXCEPTION_INVALID_HANDLE => "invalid handle",
EXCEPTION_POSSIBLE_DEADLOCK => "possible deadlock",
_ => "unknown exception code",
Copy link
Contributor

Choose a reason for hiding this comment

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

Having these extra cases will help with diagnosing errors. Thanks for adding them.

@xmclark
Copy link
Contributor

xmclark commented May 6, 2019

bors r+

1 similar comment
@syrusakbary
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request May 6, 2019
414: Exception logging (win32): Handle error codes correctly, add some more strings r=syrusakbary a=hrydgard

Ran into a situation with an unknown exception from Cranelift (will probably report that one separately). Turns out the signum was "1" though which does not seem to correspond to any of the Windows error codes, except possibly STATUS_GUARD_PAGE which is 0x80000001, but only if we lost the top bit somewhere.

On Windows, exceptions seemed to be trapped by callProtected, which is implemented here: https://github.com/wasmerio/wasmer/blob/cade9a666f5dfedfc9352718988aa26f21b028f4/lib/win-exception-handler/exception_handling/exception_handling.c . It did not seem to correctly store and retrieve the exception code, instead always returning 1: ```longjmp(jmpBuf, 1);```

So I fixed it. And now the log output looks like this:

```
unhandled trap at 1560d5e7bab - code #c0000005: segmentation violation
```


Co-authored-by: Henrik Rydgård <henrik.rydgard@embark-studios.com>
Co-authored-by: Syrus Akbary <me@syrusakbary.com>
Co-authored-by: Mackenzie Clark <mackenzie.a.z.c@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 6, 2019

@bors bors bot merged commit 10b4a08 into wasmerio:master May 6, 2019
surban pushed a commit to rust-wasi-web/wwrr that referenced this pull request Nov 9, 2024
Update Vite config, use the bundled SDK for FFMPEG example
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.

3 participants