Track submissions that fail during HAL submit - #10099
Open
kuntal-devrat wants to merge 2 commits into
Open
Conversation
If the HAL submit call fails, the command lists may already have been enqueued (e.g. a DX12 Signal failing after ExecuteCommandLists succeeded). Register the submission with the lifetime tracker before returning the error, so that a concurrent Device::maintain cannot observe an empty queue and release GPU resources while the device is being lost but the GPU may still be executing the submitted command lists.
Contributor
|
I don't think we can put failed submissions into the life tracker the same way we would successful submissions. At the very least it would require some analysis of backend APIs to justify why that is a safe thing to do. It does seem like we may need to do something to defer dropping Do you know why your submits are failing? Also note we have a pull request template, please use it for future PRs. |
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.
Summary
Queue::submit_pending_submissionreturns the HAL submit error without registering the submission in the lifetime tracker. This is a race withDevice::maintain:Signalfailing afterExecuteCommandListssucceeded).handle_hal_errormarks the device lost, and thecommand_index_guard(write) is dropped when the error is returned.Device::maintainthen observes!is_valid && queue_empty, callsrelease_gpu_resources, and destroys buffers/allocations that the failed submission's command lists may still reference while the device is being lost but the GPU may still be executing.This is the only remaining window in the submit/maintain path where in-flight work can be released without being tracked. All other exits from
submit_pending_submissionhappen before anything is enqueued, andmaintain'squeue_emptycheck is already safe on the happy path (the write guard is held until aftertrack_submission).Fix
On HAL submit failure, register the submission with the lifetime tracker before returning the error.
queue_emptythen staysfalse, sorelease_gpu_resourcescannot run while the failed submission's command lists may be in flight. On a lost device the failed submission is never triaged (fence waits fail), so it stays tracked until the queue/device is dropped — which is the correct behavior; resources are released at drop instead of mid-flight.Found during the investigation of #10085 (heap corruption under concurrent compute dispatch on Intel D3D12). This closes the last provable race in the submit/maintain path; the crash itself did not reproduce in this window (see the issue thread for the full evidence).
Testing
cargo check -p wgpu-coreclean.