Review report

bitcoin/bitcoin: PR #35990

2 suggestions

Earlier concerns neither republished nor resolved: 1 major finding. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Page-fit checks omit layout overhead and record endpoints

The aggregate limit omits header and index space, leaving the full-page fixture 66 bytes below the checked boundary, while records can still extend outside their page.

Location: src/wallet/migrate.cpp:445 (head).

Details and suggested fix

records_size starts at zero in both RecordsPage and InternalPage, but the 26-byte header and 2 * entries index bytes also occupy the page. The only position guard rejects backward offsets; file-wide reads can therefore accept records outside their referenced page when later bytes are available. Per-page retained record data is already bounded, and the missing endpoint checks predate this PR, so this is a hardening suggestion. Include PageHeader::SIZE + 2 * m_header.entries in the aggregate total and reject endpoints beyond m_page_size: index + 3 + len for data, index + 12 for overflow references, and index + 12 + len for internal records. Valid BDB pages satisfy these bounds. This also makes bdbro_full_page_parses reach the accounting limit: its records currently total 446 bytes, so changing > to >= or double-counting every record header, giving 506 bytes, would still pass. Add a one-byte-over rejection case to pin the comparison.


Link

[suggestion] · Overflow-sharing tests do not cover references from different leaves

Resetting visited_overflow per leaf would leave the new tests passing while allowing different leaves to read and retain separate copies of the same overflow chain.

Location: src/wallet/test/db_tests.cpp:486 (head).

Details and suggested fix

Both references in bdbro_overflow_chain_shared_by_records belong to leaf page 3, and the cycle fixture revisits a page within one chain. Neither distinguishes the correct tree-wide set from one recreated inside the BTREE_LEAF case. Add a fixture with a level-2 internal root at page 3 pointing to distinct level-1 leaves 4 and 5. Give each leaf a distinct key and an overflow value referencing the same terminating one-byte chain on page 6, then expect Overflow page referenced more than once. This clears the btree-revisit, level and record-size checks and pins the intended lifetime of the overflow set.


Coverage details

Earlier concerns

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