Track submissions that fail during HAL submit - #10099
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.
|
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. |
|
Thank you for the review @andyleiserson. You are correct — registering failed submissions in the life tracker needs careful backend API analysis before it can be considered safe. The original motivation (preventing release_gpu_resources from running while the GPU may still be executing) was sound, but the mechanism is not proven. Withdrawing this PR. The confirmed crash (#10085) is addressed by the separate drain-loop fix in #10102 which targets the Queue::drop race. If the partial-success deferred-drop problem surfaces independently it should be addressed with proper backend API analysis as a separate PR. |
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.