Review report

core: PR #36525

1 minor finding · 2 suggestions

Earlier concerns neither republished nor resolved: 3 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Failure cleanup can destroy a template still used by submitSolution()

On timeout or a loop exception, cancelling the Python tasks can leave a native submission running while cleanup destroys its template on the other IPC worker.

Location: test/functional/interface_ipc_mining.py:843 (head).

Details and suggested fix

Cancelling the tasks and gathering their exceptions does not establish completion of their server-side calls. stack.aclose() then sends destroy(reader_ctx) without draining writer_ctx. ServerCall releases its cancellation lock during the native invocation, while invokeDestroy() resets m_impl directly. The retained thisCap() protects the proxy's lifetime, not its implementation against explicit destruction. If cleanup overlaps the writer's remaining accesses to the template or its mutex, it can cause a secondary crash or sanitizer report that obscures the original test failure. Successful runs drain normally, and the vulnerable part of submitSolution() is short. Stop both loops cooperatively and shield outstanding IPC calls while draining them within a bound. If draining times out, skip explicit destroy() and release the capability or connection so the retained call references defer implementation cleanup.


Optional improvements

Link

[suggestion] · Concurrent-access test can leave a headers-only best header

An unground nonce can pass regtest proof of work and leave a headers-only best header, which the unchanged-height assertion does not detect.

Location: test/functional/interface_ipc_mining.py:822 (head).

Details and suggested fix

CreateNewBlock() initializes nNonce to zero, and this fixture submits it unchanged after stripping only the coinbase witness. If the reconstructed header meets the regtest target, AcceptBlockHeader() stores it before contextual validation rejects bad-witness-nonce-size as BLOCK_MUTATED. InvalidBlockFound() deliberately leaves that header unfailed. The node can therefore retain a best header one block ahead of the active tip, causing a later default createNewBlock() to enter the three-second minimum cooldown. There is no current downstream failure because run_low_height_test() immediately resets the chain. Make the rejected input deterministic by setting block.hashMerkleRoot = block.calc_merkle_root() and incrementing the nonce until proof of work fails. This preserves the mutation-versus-getter overlap because AddMerkleRootAndCoinbase() still runs before validation.


Link

[suggestion] · Concurrent IPC coverage misses template access during waitNext()

The tests do not protect the current guarantee that a blocked waitNext() leaves the same template available for getters and submissions on another worker.

Location: test/functional/interface_ipc_mining.py:840 (head).

Details and suggested fix

waitNext() snapshots the parent hash and total fees through short-lived getter locks, then waits without m_mutex. This fixture only overlaps getters with submitSolution(). The existing interruption test uses interruptWait(), which takes the notification mutex rather than the template mutex. Holding m_mutex across the manager wait could therefore leave these tests passing while blocking another worker's getter or solution submission until the wait ends. Extend the two-context fixture with a long waitNext() using the default feeThreshold=MAX_MONEY and an unchanged tip with a recent timestamp. Confirm that the server has started waiting, require a getter on the other context to finish within a short bound, then call interruptWait() and await the wait before destroying the template. The recent timestamp prevents regtest's 20-minute minimum-difficulty refresh from ending the wait early.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.