[llvm] f8ea2f6 - [Support] Clarify CrashRecoveryContext exception codes on Windows. NFC
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 15:04:13 PST 2023
Author: Alexandre Ganea
Date: 2023-02-08T18:03:58-05:00
New Revision: f8ea2f6e93c139a2bbe7f3ed6b8f53532a3d3a0d
URL: https://github.com/llvm/llvm-project/commit/f8ea2f6e93c139a2bbe7f3ed6b8f53532a3d3a0d
DIFF: https://github.com/llvm/llvm-project/commit/f8ea2f6e93c139a2bbe7f3ed6b8f53532a3d3a0d.diff
LOG: [Support] Clarify CrashRecoveryContext exception codes on Windows. NFC
Differential revision: https://reviews.llvm.org/D143609
Added:
Modified:
llvm/lib/Support/CrashRecoveryContext.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/CrashRecoveryContext.cpp b/llvm/lib/Support/CrashRecoveryContext.cpp
index e96a9b59d834..f53aea177d61 100644
--- a/llvm/lib/Support/CrashRecoveryContext.cpp
+++ b/llvm/lib/Support/CrashRecoveryContext.cpp
@@ -431,7 +431,10 @@ bool CrashRecoveryContext::RunSafely(function_ref<void()> Fn) {
[[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::RunSafely(function_ref<void()> Fn) {
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;
More information about the llvm-commits
mailing list