Repository navigation
Conversation
trace_mem reads XCL_TRACE_MEM on its first call. When the variable is unset that read sets the thread's last error to 203 (ERROR_ENVVAR_NOT_FOUND), which replaced the error the traced call had just set. XMemAllocDefault's ERROR_NOT_ENOUGH_MEMORY, for one, reached the title as 203 when it was the process's first trace. xmem_and_physical_page_overflows_fail_cleanly failed for that reason whenever it ran before every other test that traces: always alone, and in some runs of the whole module. trace_mem now runs under keep_last_error, which puts the error back after it. Test: tracing_keeps_the_last_error. It fails without the restore, in any test order. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Rebased on main d4f17ca (adeac80). The only conflict was the test module, next to the affinity tests #221 added; both are kept. 🤖 Claude Opus 5.5 |
Kalmarv
force-pushed
the
fix/kernelx-test-flake
branch
from
November 23, 2026 21:26
594f63a to
adeac80
Compare
Owner
|
Merged into main (0f34407) as 594f63a, the head before your rebase - the rebased one has the same content (main and your head agree on every file it touches), so GitHub does not show it as merged; closing by hand. Checked on an RX 9070 (RDNA4): |
This was referenced Nov 23, 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.
hle::kernelx::tests::xmem_and_physical_page_overflows_fail_cleanlyfails on main now and then (last error 203 where 8 is expected), now that CI runs the tests. The cause is in the code, not the test.Cause
trace_memreadsXCL_TRACE_MEMinto aOnceLockon its first call. With the variable unset,GetEnvironmentVariableWsets the thread's last error to 203 (ERROR_ENVVAR_NOT_FOUND).XMemAllocDefaultand theVirtualAllochooks trace after the call has set its error. So the first traced call in a process replaced its own error with 203:XMemAllocDefault(usize::MAX, 0)reported 203 instead ofERROR_NOT_ENOUGH_MEMORY. A title would see the same.The test fails whenever it is the process's first caller of
trace_mem. That happens every time when it runs alone, and in some runs of the whole module, depending on which test thread gets there first.Change
trace_memruns its body underkeep_last_error, a 6-line helper that saves the thread's last error and puts it back. That covers the first-call lookup and the logging.Tested
Windows 11, MSVC, debug, CPU only; no GPU device is created by these tests.
cargo test -p xcl --lib -- --exact hle::kernelx::tests::xmem_and_physical_page_overflows_fail_cleanly, 10 runs each: main af20b4b fails 10 of 10 (left: 203, right: 8); this branch (594f63a) passes 10 of 10.hle::kernelxwith the library test binary built from each commit, 30 runs each: main af20b4b fails 9 of 30, every time in this test with 203; this branch fails 0 of 30 (16 tests per run, including the new one).tracing_keeps_the_last_error. It setsERROR_NOT_ENOUGH_MEMORY, then checks that the error survives an unset-variable lookup underkeep_last_error, and atrace_memcall. It doesn't depend on test order. With the restore removed it fails with 203.Not tested
XCL_TRACE_MEMlookup (trace_mem_on, reached fromreserved_outsideafter a reservation), which can set 203 the same way. It merges with this branch without conflicts; wrapping that lookup inkeep_last_errortoo would cover it.AI use: Claude Code, Claude Opus 5.5.