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

False Positives Returned #1545

Open
markovejnovic opened this issue Oct 25, 2024 · 2 comments
Open

False Positives Returned #1545

markovejnovic opened this issue Oct 25, 2024 · 2 comments

Comments

@markovejnovic
Copy link

I've noticed that ag yields a false positive.

Reproduction Guide

# Grab yourself a copy of linux (I was working on the given commit)
mkdir linux && cd linux && git init
git remote add origin https://github.com/torvalds/linux.git
git fetch --depth 1 origin 89f5e14d05b4852db5ecdf222dc6a13edc633658
git checkout FETCH_HEAD

# Run ag searching for a certain fadvise.sh
ag -l -u -Q foo . | grep fadvise.sh

You will notice that this spits out

tools/perf/trace/beauty/fadvise.sh

Searching with grep, however, shows that there is no mention of foo within fadvise.sh.

grep foo tools/perf/trace/beauty/fadvise.sh

yields nothing.

System Details

ag --version

ag version 2.2.0

Features:
  +jit +lzma +zlib

uname -a

Linux fedora 6.10.10-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 12 18:26:09 UTC 2024 x86_64 GNU/Linux

cat /etc/os-release

NAME="Fedora Linux"
VERSION="40 (Workstation Edition)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:40"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=40
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=40
SUPPORT_END=2025-05-13
VARIANT="Workstation Edition"
VARIANT_ID=workstation

dnf info the_silver_searcher

Name         : the_silver_searcher
Version      : 2.2.0^2020704.5a1c8d8
Release      : 8.fc40
Architecture : x86_64
Size         : 122 k
Source       : the_silver_searcher-2.2.0^2020704.5a1c8d8-8.fc40.src.rpm
Repository   : @System
From repo    : fedora
Summary      : Super-fast text searching tool (ag)
URL          : https://github.com/ggreer/the_silver_searcher
License      : ASL 2.0 and BSD
Description  : The Silver Searcher is a code searching tool similar to ack,
             : with a focus on speed.

Current Progress

I have not performed any investigation where this unexpected result may be coming from.

@markovejnovic
Copy link
Author

And actually, as a matter of fact, the number of false positives is significantly larger than that singular file. I'm attaching a list of false positives.
false_positives.log

The same strategy as described in the main issue body can be employed to confirm these are in fact false positives

cat false_positives.log | xargs grep foo

yields nothing.

The false positive rate is 844/99138 (where 99138 comes from find -type f | wc -l) which is about 0.85%.

@BurntSushi
Copy link

BurntSushi commented Oct 26, 2024

Try the search directly, and the issue should be clear:

$ ag foo tools/perf/trace/beauty/fadvise.sh
# reliably process on arch FOO a perf.data file collected by 'perf trace

ag uses "smart case" by default, where case insensitive search is automatically enabled in some cases (e.g., when the pattern does not contain any uppercase characters). -s will disable it:

$ ag -s foo tools/perf/trace/beauty/fadvise.sh
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants