Fixes #1824: concurrent `BufferRecycler` pool-link lifecycle races #1825
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 259 lines diff across 3 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.333
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1825"
general
weight: 0.35
franz1981
Fixes: #1824
Summary
Make
BufferRecyclerpool-link operations atomic using the existing array-elementVarHandle.Previously, concurrent
releaseToPool()calls could read the same pool reference before either cleared it, allowing the same recycler to be returned more than once.Concurrent
withPool()calls could also both observe an unlinked recycler and overwrite each other's pool association.Changes
SLOTS.getAndSet()inreleaseToPool()to atomically retrieve and clear the pool reference, preventing duplicate releases of the same link.SLOTS.compareAndSet()inwithPool()so only one concurrent caller can establish a pool link.SLOTS.getVolatile()inisLinkedWithPool()for consistent visibility of the pool-link state.The changes reuse the existing
VarHandlewithout introducing additional objects or changing the recycler's memory layout.Testing
Before the fix, both new regression tests failed under concurrent execution:
After the fix, all related tests passed:
43 tests, 0 failures, 0 errors
The module-path override was used to work around a local JUnit module-resolution issue; no build configuration changes were made.
Scope
The regression tests exercise concurrent calls to the low-level
BufferRecyclerlifecycle methods. They do not establish that concurrent parser/generatorclose()calls are supported.This change prevents multiple callers from releasing the same pool link, but it does not protect a newly acquired lease from a stale caller attempting to release it.
The concurrent tests are scheduling-dependent stress tests.
Related to #1802 and #1653.