Repository navigation
Frees the env when open fails - #45
Merged
Merged
Conversation
kasperisager
requested changes
Nov 13, 2026
Co-authored-by: Kasper Isager Dalsgarð <kasperisager@hey.com>
kasperisager
approved these changes
Nov 13, 2026
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.
Problem
rocksdb__on_openhands the composite env tooptions.envwithrelease(), and onlyrocksdb__on_closedeletes it. When the open failsdb->handlestays null, so close returns early and the env leaks on every failed open. rocksdb-native's ASan job caught it once a test opened a locked database (holepunchto/rocksdb-native#128).Proposal
unique_ptruntil the open succeeds, then release it to the database as beforeDB::Openfails or thewal_filter_prefixescheck rejects it firstTests
open-lockedopens a database, then opens the same path again so the secondDB::Openfails on the lock.CI here doesn't enable leak detection, so this was checked locally with
leaks --atExiton a non-sanitized debug build:open-lockedandread-only-wal-filterboth report 3 leaks (528 bytes, rooted at theCompositeEnvWrapperfromNewCompositeEnv) without the change and 0 with it. The full suite passes under ASan, so freeing the env after a failed open doesn't trip a use-after-free.