Fix race between `DevBuffer` initialization and non-blocking streams #1107
All Vouch review confidence checks passed
Residual risk 0.13 = Change Risk (0.33) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 153 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.301
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1107"
general
weight: 0.35
vyasr
Summary
DevBufferzeroes (and optionally fills) its memory withcudaMemsetandcudaMemcpyon the legacy default stream. These calls can return before the work completes, and the legacy default stream does not order againstCU_STREAM_NON_BLOCKINGstreams. A test that creates aDevBufferand immediately copies into it on a non-blocking stream can have its copy overwritten by the late zeroing.This made
SHIM_CUDA_TESTflaky: a data mismatch in a different test (single_entry,copy_disjoint_rangesorsingle_copy_wrapper) on each run. The fix synchronizes the default stream at the end of eachDevBufferinitialization path, so the constructor returns with the buffer fully initialized.write_read_asyncintest_basic_io.cppalso mixesDevBufferwith a non-blocking stream and may be exposed to the same race. I haven't seen it fail.Testing
SHIM_CUDA_TEST: 25 of 25 consecutive runs pass with this change. Before, it failed in most runs.cteston WSL2 (RTX 2070 Super): 25 of 27 pass.BASIC_IO_TESTandOBSERVATION_TESTfail on that machine withCUDA_ERROR_ILLEGAL_ADDRESSinposix_io.hpp(device writes), which is a separate WSL2 driver issue unrelated to this change.