Skip to content
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

^$ erroneously matches around multiples of 4096 #980

Closed
jleedev opened this issue Jul 13, 2018 · 1 comment · Fixed by #1017
Closed

^$ erroneously matches around multiples of 4096 #980

jleedev opened this issue Jul 13, 2018 · 1 comment · Fixed by #1017
Labels
bug A bug. libripgrep An issue related to modularizing ripgrep into libraries.
Milestone

Comments

@jleedev
Copy link

jleedev commented Jul 13, 2018

What version of ripgrep are you using?

ripgrep 0.8.1
-SIMD -AVX

How did you install ripgrep?

cargo install
rustc 1.27.0 (3eda71b00 2018-06-19)

What operating system are you using ripgrep on?

Linux 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Linux 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

Describe your question, feature request, or bug.

~$ yes | rg -n ^$ | head 
2:
4098:
8195:
12292:
16389:
20486:
24583:
28680:
32777:
36874:

If this is a bug, what is the expected behavior?

yes | rg ^$ should not find any matches.

This also seems to break line numbers on any pattern that could possibly match a blank line.

(I was searching for ^.{0,12}$ in a file that contains no empty lines and was surprised to find empty lines. My workaround was to change the pattern to ^{1,12}$, but I was looking at incorrect line numbers until then.)

~$ yes | rg -C1 -n ^$ | head 
1-y
2:
3-y
--
4097-y
4098:
4099-y
--
8194-y
8195:

This looks similar to #441, but that's only at the end of file.

@BurntSushi
Copy link
Owner

@jleedev Great bug. I suspect this is actually the similar or same bug as #441. The tipoff here is the multiple size, which seems close to lining up with the internal buffer size used by ripgrep, which probably triggers a similar condition as being at the end of a file.

This should be fixed in libripgrep. I'll confirm this bug and add a regression test there.

@BurntSushi BurntSushi added bug A bug. libripgrep An issue related to modularizing ripgrep into libraries. labels Jul 13, 2018
@BurntSushi BurntSushi added this to the libripgrep milestone Jul 13, 2018
BurntSushi added a commit that referenced this issue Aug 19, 2018
This commit updates the CHANGELOG to reflect all the work done to make
libripgrep a reality.

* Closes #162 (libripgrep)
* Closes #176 (multiline search)
* Closes #188 (opt-in PCRE2 support)
* Closes #244 (JSON output)
* Closes #416 (Windows CRLF support)
* Closes #917 (trim prefix whitespace)
* Closes #993 (add --null-data flag)
* Closes #997 (--passthru works with --replace)

* Fixes #2 (memory maps and context handling work)
* Fixes #200 (ripgrep stops when pipe is closed)
* Fixes #389 (more intuitive `-w/--word-regexp`)
* Fixes #643 (detection of stdin on Windows is better)
* Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird)
* Fixes #764 (coalesce color escapes)
* Fixes #922 (memory maps failing is no big deal)
* Fixes #937 (color escapes no longer used for empty matches)
* Fixes #940 (--passthru does not impact exit status)
* Fixes #1013 (show runtime CPU features in --version output)
BurntSushi added a commit that referenced this issue Aug 20, 2018
This commit updates the CHANGELOG to reflect all the work done to make
libripgrep a reality.

* Closes #162 (libripgrep)
* Closes #176 (multiline search)
* Closes #188 (opt-in PCRE2 support)
* Closes #244 (JSON output)
* Closes #416 (Windows CRLF support)
* Closes #917 (trim prefix whitespace)
* Closes #993 (add --null-data flag)
* Closes #997 (--passthru works with --replace)

* Fixes #2 (memory maps and context handling work)
* Fixes #200 (ripgrep stops when pipe is closed)
* Fixes #389 (more intuitive `-w/--word-regexp`)
* Fixes #643 (detection of stdin on Windows is better)
* Fixes #441, Fixes #690, Fixes #980 (empty matching lines are weird)
* Fixes #764 (coalesce color escapes)
* Fixes #922 (memory maps failing is no big deal)
* Fixes #937 (color escapes no longer used for empty matches)
* Fixes #940 (--passthru does not impact exit status)
* Fixes #1013 (show runtime CPU features in --version output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug. libripgrep An issue related to modularizing ripgrep into libraries.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants