AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 17 Bitcoin

Merge bitcoin/bitcoin#36447: test: Misc fixes for pending validation events races

Public commit record

What the developer wrote

Authored by merge-script

100/100 · Strong
Merge bitcoin/bitcoin#36447: test: Misc fixes for pending validation events races

fa466dea808dedfc281cdff842cbefafae574d8a test: Avoid pending validation events from TestChain100Setup (MarcoFalke)
fa339713dbc58e36b0da0f2f1cce8a231939893f test: Drain all validation events before stopping indexes (MarcoFalke)
fa21ac647dc2e28f3b67ea0f057393a3b61e0aa6 test: [move-only] wallet rescan tests to separate TU (MarcoFalke)

Pull request description:

`TestChain100Setup` enqueues 100 validation events from blocks. Unit tests using that setup and their own validation events may run into non-determinism and even intermittent test failures.

Fix all issues by draining the pending validation events in the ctor.

This can be tested with a diff like:

```diff
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index 128f14a6d5..2ea3ec8d4c 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -14,2 +14,3 @@
#include <primitives/transaction.h>
+#include <random.h>
#include <util/check.h>
@@ -156,2 +157,4 @@ void ValidationSignals::SyncWithValidationInterfaceQueue()

+static FastRandomContext g_rnd{};
+
// Use a macro instead of a function for conditional logging to prevent
@@ -168,2 +171,3 @@ void ValidationSignals::SyncWithValidationInterfaceQueue()
LOG_EVENT("%s", local_log_msg); \
+ UninterruptibleSleep(1ms * g_rnd.randrange(105)); \
local_event(); \
```

and then running the test `scan_for_wallet_transactions_attach_chain` a few times.

Or master (or the first commit), it should fail with: `error: scan_for_wallet_transactions_attach_chain": check wallet->mapWallet.size() == static_cast<size_t>(NEW_BLOCKS + 1) has failed [7 != 6]`.

(Also included is a commit to move-only the many rescan tests to a separate file)

(Also included is a commit to fix unsafe index shutdowns in tests)

ACKs for top commit:
willcl-ark:
reACK fa466dea808dedfc281cdff842cbefafae574d8a
sedited:
ACK fa466dea808dedfc281cdff842cbefafae574d8a

Tree-SHA512: 3e3e57f373f150fecaef397e95ff0d6a120fea1fd7768e4de4f79708ed09e6b73311afb662a4d7967b5beddc53d28677e3707208e0da95752139d9adba76d559
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes timing problems in Bitcoin Core's own unit and benchmark tests. It does not change how the live Bitcoin node behaves. The changes make test setups wait for background 'validation' notifications to finish before tests run or shut down, which removes random test failures and unsafe shutdown races during testing. A large block of wallet rescan tests was also moved to a new file with no functional changes.

Recommended action

No production action needed. This is a test-hardening change. Developers running CI or local tests should ensure the updated test utilities are used; downstream backports should include all three commits to avoid intermittent test failures.

Security signals we found

01

Race condition in test shutdown sequence (validation callbacks vs. index destruction)

02

Non-deterministic test failures due to pending validation-interface events

03

Unsafe memory races during test index teardown

04

Test-only synchronization hardening

Risk score

Why this scored 17/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 2/15
Confidence 9/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.