Skip to content

Fix _Py_ThreadId() on Windows ARM64 with MinGW - #157252

Closed
christianaurichzm wants to merge 1 commit into
python:mainfrom
christianaurichzm:fix-threadid-mingw-arm64
Closed

christianaurichzm wants to merge 1 commit into
python:mainfrom
christianaurichzm:fix-threadid-mingw-arm64

Conversation

@christianaurichzm

@christianaurichzm christianaurichzm commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

The `__MINGW32__ && _M_ARM64` branch calls `__getReg(18)`, mirroring the MSVC
branch above it. That intrinsic is not available there: for a `*-windows-gnu`
target clang's `intrin.h` defers to mingw-w64's, which declares `__getReg`
only behind `__MACHINEIA64`, and GCC provides no corresponding builtin. The
branch is not GCC-specific either, since mingw-w64's `_mingw_mac.h` defines
`_M_ARM64` whenever `__aarch64__` is defined.

Falling through to the generic `__aarch64__` branch would not be correct:
Windows ARM64 keeps the thread environment block in `x18`, while `tpidr_el0`
is not the Windows thread pointer and reads as 0 on every thread, which would
collide with `_Py_UNOWNED_TID`. Read `x18` directly, as mingw-w64's own
`NtCurrentTeb()` does for aarch64.
@python-cla-bot

python-cla-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@christianaurichzm
christianaurichzm marked this pull request as draft September 10, 2026 04:53
@christianaurichzm
christianaurichzm marked this pull request as ready for review September 10, 2026 05:01
@christianaurichzm
christianaurichzm marked this pull request as draft September 10, 2026 05:02
@christianaurichzm
christianaurichzm deleted the fix-threadid-mingw-arm64 branch September 10, 2026 05:02
@christianaurichzm christianaurichzm changed the title gh-157212: Fix _Py_ThreadId() on Windows ARM64 with MinGW Fix _Py_ThreadId() on Windows ARM64 with MinGW Sep 29, 2026
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.

1 participant