Fix Windows crashes in Python XRT cached runtime#3100
Open
thomthehound wants to merge 4 commits into
Open
Conversation
Signed-off-by: thomthehound <thomthehound@gmail.com>
Signed-off-by: thomthehound <thomthehound@gmail.com>
jgmelber
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a high-severity issue in the Windows Python XRT runtime path. The cached runtime previously destroyed XRT objects in an unsafe order, which caused access violations on Windows and made the Python wrapper unreliable on that platform.
This was an instruction BO lifetime problem.
hostruntime.pycould (and sometimes deliberately) let an instruction BO outlive thekernel/hw_contextstate it depended upon. Linux tolerates that ordering, but Windows does not. This patch makes the ownership explicit and destroys cached XRT objects in the same dependency order that is already enforced by RAII when using C++. This correctness/hygiene fix does not change observable Linux behavior, but it is required for reliable Windows Python execution.It also tightens the cache bookkeeping around context eviction, removes platform-specific assumptions, and makes runtime-owned instruction BOs use the runtime's existing XRT device instead of creating a fresh
xrt.device(0)so ownership can be tracked correctly.Changes
kernel/hw_context.hw_contextcreation after evicting cached contexts when context slots are exhausted.hw_contextlimit.np.asarray(...)instead ofnp.array(..., copy=False)for NumPy 2.x compatibility.Tests
I added C++ lit coverage for the lifetime-ordering issue:
XFAILon Windows but should pass on Linux.These tests depend on #3075; without it, they fail due to lit syntax drift.