Repository navigation
Conversation
…he race retries lazy::handler commits a lazy page on its first access. When two threads fault on one page at once, the first removes it from LAZY and commits it; the second either finds it already removed (commit returns false) or no longer lazy, passes the fault on, and the process dies on a write to memory that is committed read-write by the time the crash is logged. A fault on a page that is now committed read-write is retried. The retail game crashed this way about two minutes into play (two threads building objects in one page, at the same millisecond). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
Contributor
|
This is a duplicate of #244 in pretty sure |
Author
|
Closing as a duplicate of #244, which fixes the same race and was opened first. I hit the same two-thread crash in the same title and confirmed the fix there: past the point where it used to crash. |
Contributor
|
This fixes the race: 10 of 10 runs pass on each of the three race tests below, all of which abort main Finding: an endless retry on a genuine fault.
Tested
Not tested
🤖 Claude Opus 5.5 |
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.
What happened
About two minutes into play (in the world, frame ~1400), the retail game crashed. Two threads faulted at the same millisecond in the same 64 KiB page:
(The region part comes from a local
VirtualQueryin the crash logger, not part of this PR.) By the time the crash is logged, the page is committed read-write. That is a lazy physical page from 38b05b7's handler, which one thread committed while the other was faulting on it.Cause
lazy::handlerfirst checksLAZYunder a read lock, thencommittakes the write lock, removes the page and commits it. When two threads fault on one page:commitreturns false; orLAZY.In both cases it returns
EXCEPTION_CONTINUE_SEARCHand the process dies.Change
If the page of a read or write fault is now committed
PAGE_READWRITE, the handler returnsEXCEPTION_CONTINUE_EXECUTION, so the access is retried. A read or write on such a page cannot fault again, so this cannot loop.Testing
threads_racing_on_a_lazy_page_all_go_on: 8 threads write into the same 64 lazy pages behind a barrier.0xc0000005(3 runs out of 3).cargo test --release -p xcl --lib: 612 passed, 0 failed. A second run while the game was using the GPU had GPU-test failures (gpu_sparse_vram_descriptors_buffers_and_xmem,gpu_float_compares_random, …). They pass alone and on a quiet GPU.🤖 Generated with Claude Code
https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA