ignore: fix panic recovery after filter_entry panic#3344
Open
lopopolo wants to merge 2 commits intoBurntSushi:masterfrom
Open
ignore: fix panic recovery after filter_entry panic#3344lopopolo wants to merge 2 commits intoBurntSushi:masterfrom
lopopolo wants to merge 2 commits intoBurntSushi:masterfrom
Conversation
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.
Summary
This fixes panic recovery in
ignore::Walkafter a panickingfilter_entrypredicate.Before this change,
Walk::nextcalledfilter_entryon a directory before it pushed the child ignore matcher. If the predicate panicked and the caller resumed iteration withcatch_unwind, the laterWalkEvent::Exitstill popped an ignore frame. That could drop ignore rules for later siblings and leak paths that.ignoreshould have hidden. The new regression test demonstrates the failure by leakingxandx/file.The fix moves the child ignore-state transition ahead of the user callback so the ignore stack stays balanced across a recovered panic.
Context
I found this bug with OpenAI Codex while auditing ripgrep for bugs in the same unwind-safety class as
RUSTSEC-2026-0078. @lopopolo reviewed and validated the reproducer, patch, and PR.Validation
cargo test -p ignore filter_entry_panic_should_not_drop_ignore_rules_for_later_siblings -- --nocapturecargo test -p ignore --libcargo fmt --all --check