Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133572: Disable error reporting for invalid memory access on unsupported WinAPI partitions#133573

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
zooba merged 5 commits intopython:mainfrommaxbachmann:patch-5
May 15, 2025
Merged
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
cleanup patch
  • Loading branch information
@maxbachmann
maxbachmann authoredMay 15, 2025
commit0f9ff16ee4fe26a6dcb2aec9051c75c2efb122db
32 changes: 20 additions & 12 deletionsModules/mmapmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,12 +60,6 @@ my_getallocationgranularity (void)

#endif

#if !defined(DONT_USE_SEH) && !(defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM))
// Only the WINDOWS_DESKTOP and WINDOWS_SYSTEM API partitions support lsa handling we want to
// perform in there
#define DONT_USE_SEH
#endif

#ifdef UNIX
#include <sys/mman.h>
#include <sys/stat.h>
Expand DownExpand Up@@ -296,6 +290,24 @@ filter_page_exception_method(mmap_object *self, EXCEPTION_POINTERS *ptrs,
}
return EXCEPTION_CONTINUE_SEARCH;
}

static void
_PyErr_SetFromNTSTATUS(ULONG status)
{
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM)
PyErr_SetFromWindowsErr(LsaNtStatusToWinError((NTSTATUS)status));
#else
if (status & 0x80000000) {
// HRESULT-shaped codes are supported by PyErr_SetFromWindowsErr
PyErr_SetFromWindowsErr((int)status);
}
else {
// No mapping for NTSTATUS values, so just return it for diagnostic purposes
// If we provide it as winerror it could incorrectly change the type of the exception.
PyErr_Format(PyExc_OSError, "Operating system error NTSTATUS=0x%08lX", status);
}
#endif
}
#endif

#if defined(MS_WINDOWS) && !defined(DONT_USE_SEH)
Expand All@@ -309,9 +321,7 @@ do { \
assert(record.ExceptionCode == EXCEPTION_IN_PAGE_ERROR || \
record.ExceptionCode == EXCEPTION_ACCESS_VIOLATION); \
if (record.ExceptionCode == EXCEPTION_IN_PAGE_ERROR) { \
NTSTATUS status = (NTSTATUS) record.ExceptionInformation[2]; \
ULONG code = LsaNtStatusToWinError(status); \
PyErr_SetFromWindowsErr(code); \
_PyErr_SetFromNTSTATUS((ULONG)record.ExceptionInformation[2]); \
} \
else if (record.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { \
PyErr_SetFromWindowsErr(ERROR_NOACCESS); \
Expand All@@ -338,9 +348,7 @@ do { \
assert(record.ExceptionCode == EXCEPTION_IN_PAGE_ERROR || \
record.ExceptionCode == EXCEPTION_ACCESS_VIOLATION); \
if (record.ExceptionCode == EXCEPTION_IN_PAGE_ERROR) { \
NTSTATUS status = (NTSTATUS) record.ExceptionInformation[2]; \
ULONG code = LsaNtStatusToWinError(status); \
PyErr_SetFromWindowsErr(code); \
_PyErr_SetFromNTSTATUS((ULONG)record.ExceptionInformation[2]); \
} \
else if (record.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { \
PyErr_SetFromWindowsErr(ERROR_NOACCESS); \
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp