test(C): exercise reads on an empty DB in delete_all_keys#5
Open
ALH477 wants to merge 1 commit into
Open
Conversation
delete_all_keys deleted both keys then re-inserted, but never read the now-empty database. Add assertions that streamdb_get and streamdb_suffix_search on the emptied DB return "not found" without crashing — the exact operations that dereference db->root. This locks in the "root is never NULL" guard in streamdb_delete (which re-seeds an empty root after the prune frees it) against regressions: an earlier reverse-trie variant without that guard segfaulted here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Strengthens the existing
delete_all_keystest (C reference impl).Today it deletes both keys then re-inserts, but never reads the now-empty database — and a read is exactly what dereferences
db->root. This adds, right after the two deletes:This locks in the "root is never NULL" guard in
streamdb_delete(which re-seeds an empty root after the prune frees it). An earlier reverse-trie variant lacking that guard segfaulted on exactly this path (aget/suffix_searchafter the last key is deleted) — heap-layout-sensitive, so it looked intermittent. Currentmainalready handles it; this test makes that explicit and guards against regressions.Test-only change. Full suite passes locally (24/24) under the repo's
-Werror -pedanticbuild:Context: opened from #4.
🤖 Generated with Claude Code