Provider refusals
write_verifier: Provider declined the request because of a cybersecurity restriction. Experiments remain incomplete; static verification can continue.
1 major finding · 1 minor finding · 4 suggestions
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.
Findings
[major] · ChainMan releases its context before joining block readers
ChainMan teardown can free chain parameters before outstanding kernel block readers finish when it owns the last Context reference; no current in-tree caller using this release order was found.
Location: src/validation.cpp:1862 (head).
Details and suggested fix
The C API permits callers to release their context and options handles after creating a manager. ChainMan declares m_context after m_chainman, so destruction releases that last context reference first. With the default readers enabled, interrupted activation can leave queued or running reads; Clear() also discards futures without cancelling tasks. btck_chainstate_manager_destroy() flushes and resets coins views but does not join the readers. Their BlockManager::ReadBlock() calls still access context-owned parameters through references, while joining happens later during BlockFetcher destruction. This introduces a timing-dependent use-after-free: flushing may let the reads finish, but provides no synchronization. Previously, block reads completed synchronously during activation.
Declare m_context before m_chainman so the manager and its readers are destroyed first. Add regression coverage that releases the original handles and destroys the manager after interrupted activation.
[minor] · Reader-startup assertions race with thread scheduling
An unusually delayed second reader can fail feature_reindex.py's zero-timeout startup-log assertion on a correct node; no such failure has been observed.
Location: test/functional/feature_reindex.py:49 (head).
Details and suggested fix
The two-reader startup check uses assert_debug_log() with its default timeout=0. ThreadPool::Start() launches readers without waiting for them to run, and each reader logs from TraceThread() before doing work. One reader can finish all required reads while the other remains unscheduled, so RPC/full initialization does not order both startup messages before the assertion. The initial generation window can likewise reject a delayed startup message because it has not first observed the initially configured reader. Use a bounded timeout for positive startup checks and observe that initial reader before opening a window that forbids startup lines.
Optional improvements
[suggestion] · ReadBlockFn leaves its worker lock contract undocumented
The current callback is safe, but ReadBlockFn does not state that concurrent callbacks must avoid cs_main, which Load() holds while waiting for them.
Location: src/node/blockfetcher.h:28 (head).
Details and suggested fix
The controller-side lock annotations do not describe the std::function callback's requirements. FillQueue() copies positions and hashes under cs_main, then invokes the callback from pool tasks; Load() waits on those tasks while retaining the same lock. The production callback selects the positional ReadBlock() overload, whereas the CBlockIndex overload acquires cs_main and would deadlock in that role. Document at the typedef or constructor that callbacks may run concurrently, must not acquire cs_main, and receive copied positions and hashes so they need not inspect the block index.
[suggestion] · Cache-hit tests do not distinguish the sliding-window depth
A one-block read-ahead implementation would satisfy the existing cache-hit counts, leaving the four-result window and consume-one/refill-one behavior unprotected.
Location: src/node/blockfetcher.cpp:58 (head).
Details and suggested fix
feature_reindex.py counts Using cached block messages, but Load() waits for its future, so even one queued block gives the same sequential counts. Its two-block reorg count includes the caller-provided fork tip, and block_read_ahead_retry builds only one index entry. Add a linked index-chain test using the injected reader to record requested hashes. With two readers and enough indexed blocks, one FillQueue() should request exactly the first four; after consuming one and refilling at the next height, only one new hash should be requested, with no retained block read again. Synchronize the callback observations with promises or futures rather than sleeps.
[suggestion] · BlockFetcher lifecycle tests never hold a read in progress
The existing fetcher unit test consumes both reads, leaving nonblocking Clear() and callback lifetime during destruction unchecked.
Location: src/node/blockfetcher.cpp:35 (head).
Details and suggested fix
The retry fixture waits on both reads before leaving scope, while reorgs call Clear() before queuing a sibling. Within BlockFetcher, the current member order keeps m_read_block alive while m_pool drains and joins. Add a reader controlled by a promise or semaphore. Verify that Clear() returns while the read remains blocked and, with another worker available, that a subsequent queue/load returns the new branch's block rather than the discarded result. In a separate destruction case, release the blocked read from a helper thread and use callback-owned lifetime state to verify that callbacks finish before that state is destroyed. Avoid sleep-based scheduling.
[suggestion] · Empty-batch handling is split across two commits
The batching commit changes shared ThreadPool::Submit() behavior for empty batches, but a later fetcher guard removes its production use, obscuring which changes the feature actually needs.
Location: src/node/blockfetcher.cpp:68 at 8632c96d9924 (commit) (commit).
Details and suggested fix
In 1cd15ef7addceddd3caa23d545c48cd8a9642df7 (batching), FillQueue() submits empty vectors and ThreadPool::Submit() gains the conditional notify_all(). 8632c96d992428685224ecbe153f0cb027679443 (the later guard and API-comment follow-up) adds if (tasks.empty()) return;, so the fetcher no longer needs that utility change; the other production range caller, CoinsViewOverlay, already submits nonempty batches. Fold the guard into the batching commit and either drop the utility tweak or place it in an independently explained util: commit. This lets the batching step show its complete empty-case handling and makes any shared-utility change independently reviewable. Keeping the later follow-up separate during re-review is reasonable; this is a final-series organization suggestion, not a head defect.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Clearing the fetch queue leaves obsolete reads ahead of new work
- [suggestion]: Retain successor results when a speculative read fails