Fix panic when cursor is exhausted during fold/unfold - #48802
Closed
rtfeldman wants to merge 1 commit into
Closed
Conversation
The crash occurred at an .unwrap() on cursor.item() in BlockMap::sync (line 891) when the SumTree cursor had been exhausted. This happens when the transforms tree has fewer input_rows than the wrap snapshot expects, which can occur when a prior sync produces an inconsistent state (only caught by a debug_assert in release builds). The call chain was: Editor::on_buffer_event → DisplayMap::unfold_buffers → BlockMapWriter::fold_or_unfold_buffers → BlockMap::sync Fix: Replace the .unwrap() with graceful handling — when the cursor is exhausted, log an error, consume all remaining edits, and rebuild blocks for the remaining range. Also add a log::error at the input_rows invariant check so inconsistencies are visible in release builds.
Member
|
@rtfeldman I believe the panic here is fixed by #48809--I think we should close in favor of that since it targets the specific code that regressed here (due to my earlier PR) |
Contributor
Author
|
Cool, thanks! 🚀 |
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.
The crash was a
.unwrap()onNoneat an exhausted SumTree cursor insideBlockMap::sync. This happens when the transforms tree has fewerinput_rowsthan the wrap snapshot expects — an inconsistency from a prior sync that was only guarded by adebug_assert(compiled out in release builds).The call chain leading to the crash:
Fix:
.unwrap()with gracefulNonehandling: log an error, consume remaining edits, and rebuild blocks for the remaining range.log::error!at theinput_rowsinvariant check so inconsistencies are visible in release builds (alongside the existingdebug_assert).Release Notes: