Skip to content

skiplist: prevent Range iterator from rewinding after exhaustion#1252

Open
cong-or wants to merge 1 commit into
crossbeam-rs:mainfrom
cong-or:fix-skiplist-range-rewind
Open

skiplist: prevent Range iterator from rewinding after exhaustion#1252
cong-or wants to merge 1 commit into
crossbeam-rs:mainfrom
cong-or:fix-skiplist-range-rewind

Conversation

@cong-or

@cong-or cong-or commented May 4, 2026

Copy link
Copy Markdown

Fixes #1142 — Range iterators rewound to the first element after exhaustion.

When the bounds check failed, head was set to None. Next call interpreted
that as "haven't started yet" and searched from start_bound() again.

Added a finished flag to Range/RefRange, set only when bounds are
exceeded. Iter/RefIter left unchanged — their rewind on concurrent inserts
is intentional.

Also added FusedIterator impls for Range in base, map, and set.

@cong-or
cong-or force-pushed the fix-skiplist-range-rewind branch from e586243 to 1ab7e07 Compare May 4, 2026 21:26
range: R,
guard: &'g Guard,
_marker: PhantomData<fn() -> Q>, // covariant over `Q`
finished: bool,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Unless it's necessary for correctness, I think it's generally preferable to use fuse rather than "adding an extra flag just to provide FusedIterator's behavior".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

crossbeam_skiplist::Range rewinds to the head after it was exhausted

2 participants