Skip to content

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

Merged
bors[bot] merged 3 commits intowasmerio:masterfrom
EmbarkStudios:improve-exception-logging
May 6, 2019
Merged

Exception logging (win32): Handle error codes correctly, add some more strings#414
bors[bot] merged 3 commits intowasmerio:masterfrom
EmbarkStudios:improve-exception-logging

Conversation

@hrydgard
Copy link
Copy Markdown

@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
Copy Markdown
Member

bors try

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

bors bot commented May 3, 2019

@bjfish bjfish requested a review from xmclark May 3, 2019 04:40
Copy link
Copy Markdown
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.

💯

}

out_result->code = (uint64_t)signum;
out_result->code = (uint64_t)caughtExceptionCode;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

xmclark commented May 6, 2019

bors r+

1 similar comment
@syrusakbary
Copy link
Copy Markdown
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
Copy Markdown
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