Files
allwpilib/upstream_utils/llvm_patches/0017-Remove-call-to-RtlGetLastNtStatus.patch
PJ Reiniger 32cd2ddf8e [upstream_utils] Remove patch that results in building with NDEBUG causing ODR issues (#8539)
Semiwrap / meson / robotpy define `NDEBUG` when building their software
in all modes, while `allwplib` only does it when building debug. This
causes the size of `DenseMap` to differ between the shared libraries
built here, and the extension modules built in `mostrobotpy`, causing
segfaults when you try to execute code that uses `DenseMap`. This is not
a problem with the robotpy code in `allwpilib`, because bazel uses the
exact same compiler flags when building the shared libraries and
pybind11 extensions.
2026-01-03 13:32:16 -08:00

49 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Tue, 17 Sep 2024 21:19:52 -0700
Subject: [PATCH 17/35] Remove call to RtlGetLastNtStatus()
---
llvm/lib/Support/ErrorHandling.cpp | 23 -----------------------
1 file changed, 23 deletions(-)
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index e813fd3faa9f76148f9802c4b7308e517df32269..d0fd67bd3c0d4cf33922cdda042531424d277951 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -214,34 +214,11 @@ void LLVMResetFatalErrorHandler() {
#include <ntstatus.h>
#include <winerror.h>
-// This is equivalent to NtCurrentTeb()->LastStatusValue, but the public
-// _TEB definition does not expose the LastStatusValue field directly.
-// Avoid offsetting into this structure by calling RtlGetLastNtStatus
-// from ntdll.dll.
-//
-// The return of this function will roughly match that of
-// GetLastError, but this lower level API disambiguates some cases
-// that GetLastError does not.
-//
-// For more information, see:
-// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm
-// https://github.com/llvm/llvm-project/issues/89137
-extern "C" NTSYSAPI NTSTATUS NTAPI RtlGetLastNtStatus();
-
// This function obtains the last error code and maps it. It may call
// RtlGetLastNtStatus, which is a lower level API that can return a
// more specific error code than GetLastError.
std::error_code llvm::mapLastWindowsError() {
unsigned EV = ::GetLastError();
- // The mapping of NTSTATUS to Win32 error loses some information; special
- // case the generic ERROR_ACCESS_DENIED code to check the underlying
- // NTSTATUS and potentially return a more accurate error code.
- if (EV == ERROR_ACCESS_DENIED) {
- llvm::errc code = RtlGetLastNtStatus() == STATUS_DELETE_PENDING
- ? errc::delete_pending
- : errc::permission_denied;
- return make_error_code(code);
- }
return mapWindowsError(EV);
}