upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-07-31 16:37:10 -0300
committerGitHub <noreply@github.com>2026-07-31 16:37:10 -0300
commit417bfed08ded5c6afaed25f4ef724b5629b13fae (patch)
tree611df88a86d7b73af6b3d65d05647e3f25c682d6 /src/main.cpp
parent59777ee34a5ab6297684b7ab8d5d93facd4ad6f3 (diff)
db: close Berkeley DB cursors instead of leaving them to the handle (#71)
Three functions open a cursor and none of them close it: CTxDB::LoadBlockIndex, CTxDB::ReadOwnerTxes and CWalletDB::LoadWallet. Berkeley DB requires every cursor to be closed before the handle it came from. ~CDB() calls Close(), which calls pdb->close() inside a catch-all that swallows whatever it returns -- so the violation was real and silent, which is this codebase's favourite kind. An open cursor also holds read locks, and that is not theoretical here: the first version of the startup chain repair (#61) opened a write transaction beside the cursor LoadBlockIndex was still holding and waited on it forever, coming up, printing its diagnosis and hanging with nothing in any log. The repair had to be moved to the caller to get clear of it. A scope guard rather than a close call at each return, because all three functions have several exits and the point is to stop relying on anyone remembering. Same fix Bitcoin made in c5c7911da. Verified: node starts, verifies 288 blocks, loads the wallet, runs the spent-flag rescan and syncs the live chain to 4422 with no Berkeley DB error anywhere and db.log still empty.
Diffstat (limited to 'src/main.cpp')
0 files changed, 0 insertions, 0 deletions