mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* segfault on invalid 'git grep' invocation
@ 2021-06-28 12:17 Matthew Hughes
  2021-06-28 18:53 ` Ævar Arnfjörð Bjarmason
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Matthew Hughes @ 2021-06-28 12:17 UTC (permalink / raw)
  To: git

Hi all,

It's my first time writing to this mailing list, so apologies in advance
for any mistakes/faux pas.


Segfault seen when running:

    $ ./git grep --and -e 'pattern' -- not_a_path

Expected Behaviour

The above invocation doesn't appear particularly valid to me, I
accidentally ran it while editing a command. Not sure if this needs
addressing, but perhaps the expected behaviour would be an error message
about it not being valid?

Compare with, running without '--':

    $ ./git grep --and -e 'pattern' not_a_path
    fatal: ambiguous argument 'not_a_path': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'

Running with a valid path:

    $ ./git grep --and -e 'pattern' -- common-main.c
    fatal: Not a valid grep expression

    $ ./git grep --and -e 'pattern' common-main.c
    fatal: Not a valid grep expression


git version:
git version
cpu: x86_64
built from commit: 670b81a890388c60b7032a4f5b879f2ece8c4558
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
compiler info: gnuc: 8.3
libc info: glibc: 2.28
$SHELL (typically, interactive shell): /bin/bash

Also reproduced on git 2.20.1 (packaged version on Debian 10)

The segfault is raised at free_pattern_expr (x=0x0) at grep.c:825 (on
commit 670b81a890388c60b7032a4f5b879f2ece8c4558)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-06-30 16:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 12:17 segfault on invalid 'git grep' invocation Matthew Hughes
2021-06-28 18:53 ` Ævar Arnfjörð Bjarmason
2021-06-28 18:58 ` [PATCH] grep: report missing left operand of --and René Scharfe
2021-06-29 17:52   ` Ævar Arnfjörð Bjarmason
2021-06-29 18:35     ` René Scharfe
2021-06-30 16:12 ` [PATCH v2] " René Scharfe

Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).