-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combination of --no-ignore, --sort, and search path of a symbolic link to a directory causes panic #1389
Comments
After further experimentation, it looks like it is the combination of the following:
I used the |
Please provide a complete reproduction, as the issue template requests. Please provide commands to setup an identical corpus, for example. |
mkdir mydir
ln -s mydir mylink
echo "text in file" >> mydir/file.txt
rg text --no-ignore --sort path # no search path is OK
rg text --no-ignore --sort path mydir # regulary directory is also OK
rg text --no-ignore --sort path mylink # symbolic link to directory is NOT OK If you either remove all ripgrep configuration files or include the |
Due to how walkdir works if symlinks are not followed, symlinks to directories are seen as simple files by ripgrep. This caused a panic in some cases due to receiving a WalkEvent::Exit event without a corresponding WalkEvent::Dir event. This is fixed by looking at the metadata of the file in the case of a symlink to determine if it's a directory. Fixes BurntSushi#1389 Signed-off-by: Nikos Filippakis <nikolaos.filippakis@cern.ch>
Hey! I wanted to contribute to ripgrep as I use it a lot, so I made a PR to fix this issue. Hope that's ok! This was caused by Lines 1036 to 1040 in 8892bf6
is_dir() . When symlinks are not followed, however, this will return false even in the case of a symlink that points to a directory. Then, when ripgrep gets an event signaling that the directory listing is over Lines 949 to 951 in 8892bf6
Ignore object which doesn't exist in this case, causing a panic.
|
Due to how walkdir works if symlinks are not followed, symlinks to directories are seen as simple files by ripgrep. This caused a panic in some cases due to receiving a WalkEvent::Exit event without a corresponding WalkEvent::Dir event. This is fixed by looking at the metadata of the file in the case of a symlink to determine if it's a directory. We are careful to only do this stat check when the depth of the entry is 0, as this bug only impacts us when 1) we aren't following symlinks generally and 2) the user provides a symlinked directory that we do follow as a top-level path to search. Fixes #1389, Closes #1397
What version of ripgrep are you using?
ripgrep 11.0.2
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)
How did you install ripgrep?
brew install ripgrep
What operating system are you using ripgrep on?
macOS Mojave 10.14.6 (18G95)
Describe your question, feature request, or bug.
When I run the following command that searches a symbolic link, ripgrep panics (after displaying output):
rg -n --hidden --no-ignore --color=always --sort path pattern ~/symbolic-link-to-directory
If this is a bug, what are the steps to reproduce the behavior?
Use the previous flags on a symbolic link to a directory.
If this is a bug, what is the actual behavior?
If this is a bug, what is the expected behavior?
Not panic.
The text was updated successfully, but these errors were encountered: