Skip to content

Fix stale slot_1 availability bit in LineListNode#32

Open
zariuq wants to merge 1 commit intoAdam-Vandervorst:masterfrom
zariuq:oruz/fix-line-list-slot1-availability
Open

Fix stale slot_1 availability bit in LineListNode#32
zariuq wants to merge 1 commit intoAdam-Vandervorst:masterfrom
zariuq:oruz/fix-line-list-slot1-availability

Conversation

@zariuq
Copy link
Copy Markdown

@zariuq zariuq commented Mar 27, 2026

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_1 is unused, it means slot_1 is unavailable because slot_0 consumed all key bytes. Two paths could shorten slot_0 below KEY_BYTES_CNT while leaving that bit set:

  • shorten_key_len::<0>
  • the single-slot drop_head_dyn path

That left slot_1 empty but still marked unavailable, which could send later insertions down the fallback split path incorrectly.

This patch:

  • clears the stale bit in shorten_key_len::<0>
  • routes the single-slot drop_head_dyn shortening path through the same helper
  • adds a debug invariant in validate_node
  • adds two focused regression tests covering both local writers of the stale state

Tests:

  • cargo test -p pathmap releases_slot_1_availability -- --nocapture

I also confirmed this fixes a real downstream crash in a Metamath/MORK consumer.

If you want an even shorter version:

Fix a stale slot_1 availability bit in LineListNode.

When slot_0 was shortened below KEY_BYTES_CNT, two paths could leave bit 12 set even though slot_1 was empty and reusable. That stale state could send later insertions down the fallback split path
incorrectly.

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 -- --nocapture

Also confirmed against a downstream Metamath/MORK reproducer.

  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.
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