Skip to content

lightningd: parent watchman's formatted blockhash strings to tmpctx - #9363

Open
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-watchman-memleak-report
Open

lightningd: parent watchman's formatted blockhash strings to tmpctx#9363
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-watchman-memleak-report

Conversation

@ksedgwic

Copy link
Copy Markdown
Collaborator

Fixes #9362 : the memleak scanner can flag the blockhash strings
watchman formats into its RPC responses -- json_add_string copies the
value, so nothing references the string afterward, and a dev memleak
check racing an in-flight response reports it as a leak. Parent them
to tmpctx, the idiom used elsewhere.

Changelog-None

json_add_string copies its value, so the strings fmt_bitcoin_blkid
allocates in json_block_processed and json_getwatchmanheight are
referenced by nothing once the call returns.  They are parented to
the response stream and freed with it, but the memleak scanner works
by searching memory for pointers to each allocation: when a dev
memleak check races an in-flight response, the unreferenced string is
reported as a leak and fails the test run (seen in a liquid CI run of
test_bwatch_add_watch_creates_datastore_entry).  Parent them to
tmpctx, the idiom used elsewhere.

Fixes: ElementsProject#9362
Changelog-None
@ksedgwic
ksedgwic requested a review from sangbida July 28, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: memleak reports for watchman's response-parented blockhash strings

1 participant