Skip to content

fix(#603): store appendVersion error path — no poisoned files entry on failed path dupe#604

Merged
justrach merged 2 commits into
release/0.2.5825from
fix/issue-603-store-append-poison
Jun 11, 2026
Merged

fix(#603): store appendVersion error path — no poisoned files entry on failed path dupe#604
justrach merged 2 commits into
release/0.2.5825from
fix/issue-603-store-append-poison

Conversation

@justrach

Copy link
Copy Markdown
Owner

What

Fixes #603 (note: merging into the release branch will not auto-close it — add it to the ship closes-list).

appendVersion's first-touch block inserted the map slot via getOrPut and only then duped the path. A failed dupe (OOM) left a poisoned entry behind: key = the caller's transient slice, value = undefined FileVersions. A retry appended into undefined memory (UB), deinit invalid-freed the borrowed key, and once the caller freed its buffer the map held a dangling key. Same error-path class as #594, in the store.

The fix scopes an errdefer self.files.removeByPtr(entry.key_ptr) to the first-touch block, so the dupe failing rolls the insert back. FileVersions.init is infallible, so the errdefer guards exactly the dupe; a later versions.append failure still leaves a valid initialized entry, which is fine.

Test plan

  • test(#603) commit: failing test (expected 0, found 1 + leak) on the release tip
  • With fix: zig build test — 23/23 steps, 808/808 tests passed

🤖 Generated with Claude Code

justrach and others added 2 commits June 11, 2026 12:07
… files entry

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n the path dupe fails

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Benchmark Regression Report

Thresholds: 10.00% and 50,000 ns absolute delta

NOISE means the percentage threshold was exceeded, but the absolute delta was too small to fail CI.

Tool Base (ns) Head (ns) Delta Abs Delta (ns) Status
codedb_bundle 108482 105343 -2.89% -3139 OK
codedb_changes 17675 10169 -42.47% -7506 OK
codedb_context 1043649 973409 -6.73% -70240 OK
codedb_deps 380 381 +0.26% +1 OK
codedb_edit 40028 73442 +83.48% +33414 NOISE
codedb_find 8971 9067 +1.07% +96 OK
codedb_hot 23756 28701 +20.82% +4945 NOISE
codedb_outline 35749 39116 +9.42% +3367 OK
codedb_read 20723 22766 +9.86% +2043 OK
codedb_search 30488 28879 -5.28% -1609 OK
codedb_snapshot 69539 70861 +1.90% +1322 OK
codedb_status 9746 9336 -4.21% -410 OK
codedb_symbol 51606 51099 -0.98% -507 OK
codedb_tree 18732 19744 +5.40% +1012 OK
codedb_word 11070 11591 +4.71% +521 OK

@justrach justrach merged commit 384761e into release/0.2.5825 Jun 11, 2026
2 checks passed
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.

1 participant