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

fuzz: keep backend assertions aligned to active backend

Public commit record

What the developer wrote

Authored by Lőrinc

95/100 · Strong
fuzz: keep backend assertions aligned to active backend

`TestCoinsView` switches the `CCoinsViewCache` backend during fuzzing and then queries the backend for cross-checks.
Pass the backend as a `CCoinsView*` (to make it relocatable) and retarget it when toggling between the original backend and a local empty `CCoinsView` so assertions always refer to the active backend. This will be switched to a singleton in the next commit.

Note that the previous slice-assignment (`backend_coins_view = CCoinsView{}`) was a silent noop for the db target, it only copied base-class members (none) without changing the vtable, so the backend was never actually switched.
The pointer approach makes the switch real for both targets, which revealed that when restoring the original backend after the empty one, the cache must be reset first to avoid carrying FRESH flags that were valid relative to the empty backend but invalid relative to the original (which may already contain those coins).

Co-authored-by: Anthony Towns <aj@erisian.com.au>
Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: marcofleon <marleo23@proton.me>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug in a Bitcoin Core fuzz test (an automated testing harness, not production code). The test was supposed to swap between two database backends during testing, but due to a C++ object-slicing mistake the swap never actually happened. The fix makes the swap work correctly and adds a cache reset when switching back to the original backend so that internal 'freshly created' flags don't become invalid. Because this only affects test code, it does not directly endanger live Bitcoin nodes or users' funds.

Recommended action

No production action required. Treat as a test-quality fix. Reviewers may want to confirm that the fuzz target now exercises the intended backend-switching behavior and that the reset guard correctly prevents false-positive assertions or missed bugs.

Security signals we found

01

Object slicing caused intended backend switch to be a silent no-op in fuzz test

02

Fix adds real backend pointer retargeting and cache reset on backend restore

03

FRESH flag inconsistency across different backends is explicitly mentioned as the reason for the reset

04

Only test/fuzz code is changed; no production code paths are affected

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 1/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.