Skip to content

Fix BTree leaf split ownership transfer - #49

Open
shuaimu wants to merge 2 commits into
mainfrom
codex/btree-split-owned-relocation
Open

Fix BTree leaf split ownership transfer#49
shuaimu wants to merge 2 commits into
mainfrom
codex/btree-split-owned-relocation

Conversation

@shuaimu

@shuaimu shuaimu commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • move BTree leaf-split medians out of MaybeUninit storage instead of bit-copying copyable owners
  • consume removed BTree entries with MaybeUninit::assume_init instead of assume_init_read, so an Rc-like owner is transferred exactly once and the dead slot retains no hidden strong count
  • encode both ownership fixes in the post-transpile patch pipeline and keep the patcher idempotent
  • add destructor-count regressions for the first leaf split and middle/last removals
  • load libc++ <vector> before module imports so the regression target builds without a forced include

Root cause

Both failures came from reading an initialized MaybeUninit<T> by copy where the BTree algorithm semantically moves T. Copyable owning types such as the generated Rc then left one untracked strong reference in dead node storage. The remove-path leak was also the cause of the previously observed ExtractIf use-after-free; it was not an independent defect.

Validation

  • strict C++23 standalone suite: 478/478 passed
  • full isolated ASan BTree suite: 478/478 passed with ASan errors fatal
  • focused split and remove owner-drop accounting regressions passed
  • post-transpile patcher is idempotent

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