Fix stale slot_1 availability bit in LineListNode#32
Open
zariuq wants to merge 1 commit intoAdam-Vandervorst:masterfrom
Open
Fix stale slot_1 availability bit in LineListNode#32zariuq wants to merge 1 commit intoAdam-Vandervorst:masterfrom
zariuq wants to merge 1 commit intoAdam-Vandervorst:masterfrom
Conversation
Clear the stale slot_1-unavailable bit when shorten_key_len::<0> reduces a full-width slot_0 key below KEY_BYTES_CNT with slot_1 empty. Also route the single-slot drop_head_dyn shortening path through shorten_key_len::<0> so the same invariant is preserved there. Add a debug validate_node invariant for slot_1 availability and two focused regressions covering both local writers of the stale state.
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.
Hope this isn't a waste of your time. I hardly understand it but Codex thinks it ran into and patched a small bug while working on something MORK-related. GPT-5.4 Pro and Claude Code agree it seems solid. Figure if the AIs agree, I should at least ping ya'll 🙏.
Codex's message:
This fixes a stale header invariant in
LineListNode.Bit 12 is dual-use: when
slot_1is unused, it meansslot_1is unavailable becauseslot_0consumed all key bytes. Two paths could shortenslot_0belowKEY_BYTES_CNTwhile leaving that bit set:shorten_key_len::<0>drop_head_dynpathThat left
slot_1empty but still marked unavailable, which could send later insertions down the fallback split path incorrectly.This patch:
shorten_key_len::<0>drop_head_dynshortening path through the same helpervalidate_nodeTests:
cargo test -p pathmap releases_slot_1_availability -- --nocaptureI also confirmed this fixes a real downstream crash in a Metamath/MORK consumer.
If you want an even shorter version:
Fix a stale
slot_1availability bit inLineListNode.When
slot_0was shortened belowKEY_BYTES_CNT, two paths could leave bit 12 set even thoughslot_1was empty and reusable. That stale state could send later insertions down the fallback split pathincorrectly.
This patch fixes both writers, adds a debug invariant, and adds two focused regression tests.
Tested with:
cargo test -p pathmap releases_slot_1_availability -- --nocaptureAlso confirmed against a downstream Metamath/MORK reproducer.