Fix memory leaks in corpus pruner, trieDB, and RPC pool#812
Merged
Conversation
Three leaks confirmed via pprof profiling against aave-v4-scfuzzbench (~10 MB/min combined growth): 1. Coverage maps retained in PruneSequences: checkSequenceCoverageAndUpdate only cleaned coverage from the last element. Intermediate elements held *CoverageMaps in AdditionalResults via ChainReference.Block pointers until the next loop iteration (~8 MB/min). 2. TrieDB hashdb growth: PendingBlockCommit inserts dirty trie nodes via state.Commit(), but RevertToBlockIndex never called Dereference() to release old state roots. Added Dereference on revert and Cap(16 MB) on commit as a safety net (~2 MB/min). 3. Fork-mode inflightRequests map: ClientPool.launchRequest never deleted completed entries from the map. Passed the request key through and added a deferred delete (unbounded growth). Closes #811 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PruneSequencesreplays sequences butcheckSequenceCoverageAndUpdateonly cleans coverage from the last element. Intermediate elements retain*CoverageMapsinAdditionalResultsviaChainReference.Blockpointers. Added cleanup loop for all elements after each replay, matching the pattern inCorpus.Initialize.PendingBlockCommitcallsstate.Commit()inserting dirty trie nodes, butRevertToBlockIndexnever calledDereference()to release old state roots. AddedDereferenceon revert andCap(16 MB)on commit as a safety net.inflightRequests(unbounded):ClientPool.launchRequestnever deleted completed entries from the map. Passed the request key and added a deferred delete.All three leaks confirmed via pprof profiling against aave-v4-scfuzzbench (~10 MB/min combined).
See #811 for a proposal to unify coverage cleanup long-term.
Test plan
go build ./...compilesgo vet ./...passesgolangci-lint run --timeout 5m ./chain/... ./fuzzing/...— no new warningsgo test -v -run 'TestFuzzerHooks|TestSlitherPrinter' ./fuzzing/...passesinflightRequests🤖 Generated with Claude Code