[PATCH] D143609: [Support] Clarify CrashRecoveryContext exception codes on Windows
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 14:55:24 PST 2023
aganea created this revision.
aganea added reviewers: mstorsjo, andrewng.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aganea requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Explain why these particular exception codes are used.
As suggested in https://reviews.llvm.org/D142224#4113763
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143609
Files:
llvm/lib/Support/CrashRecoveryContext.cpp
Index: llvm/lib/Support/CrashRecoveryContext.cpp
===================================================================
--- llvm/lib/Support/CrashRecoveryContext.cpp
+++ llvm/lib/Support/CrashRecoveryContext.cpp
@@ -431,7 +431,10 @@
[[noreturn]] void CrashRecoveryContext::HandleExit(int RetCode) {
#if defined(_WIN32)
- // SEH and VEH
+ // Since the exception code is actually of NTSTATUS type, we use the
+ // Microsoft-recommended 0xE prefix, to signify that this is a user error.
+ // This value is a combination of the customer field (bit 29) and severity
+ // field (bits 30-31) in the NTSTATUS specification.
::RaiseException(0xE0000000 | RetCode, 0, 0, NULL);
#else
// On Unix we don't need to raise an exception, we go directly to
@@ -445,10 +448,10 @@
bool CrashRecoveryContext::isCrash(int RetCode) {
#if defined(_WIN32)
- // On Windows, the high bits are reserved for kernel return codes. Values
- // starting with 0x80000000 are reserved for "warnings"; values of 0xC0000000
- // and up are for "errors". In practice, both are interpreted as a
- // non-continuable signal.
+ // On Windows, the code is interpreted as NTSTATUS. The two high bits
+ // represent the severity. Values starting with 0x80000000 are reserved for
+ // "warnings"; values of 0xC0000000 and up are for "errors". In practice, both
+ // are interpreted as a non-continuable signal.
unsigned Code = ((unsigned)RetCode & 0xF0000000) >> 28;
if (Code != 0xC && Code != 8)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143609.495963.patch
Type: text/x-patch
Size: 1503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230208/401f3c78/attachment.bin>
More information about the llvm-commits
mailing list