git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Johannes Schindelin" <johannes.schindelin@gmx.de>,
	"Git mailing list" <git@vger.kernel.org>,
	"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: Re: [PATCH] pickaxe: fix segfault with '-S<...> --pickaxe-regex'
Date: Sat, 18 Mar 2017 18:45:00 +0100	[thread overview]
Message-ID: <CAM0VKjknLpCyQfY+ie3sfGemwhyad3Tk-5fHdeTSz2-WTw7NoQ@mail.gmail.com> (raw)
In-Reply-To: <20170318151239.17196-1-szeder.dev@gmail.com>

On Sat, Mar 18, 2017 at 4:12 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:
> Make sure that the buffer size is reduced on each iteration as the
> buffer pointer is advanced, thus maintaining the correct end of buffer
> location.
>
> The new test is flaky, I've never seen it fail on my Linux box, but
> this is expected according to db5dfa331 (regex: -G<pattern> feeds a
> non NUL-terminated string to regexec() and fails, 2016-09-21).  And
> based on that commit message I would expect the new test without the
> fix to fail reliably on Windows.
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>
>  diffcore-pickaxe.c      | 5 ++++-
>  t/t4062-diff-pickaxe.sh | 5 +++++
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
> index 9795ca1c1..03f84b714 100644
> --- a/diffcore-pickaxe.c
> +++ b/diffcore-pickaxe.c
> @@ -85,8 +85,11 @@ static unsigned int contains(mmfile_t *mf, regex_t *regexp, kwset_t kws)
>                        !regexec_buf(regexp, data, sz, 1, &regmatch, flags)) {
>                         flags |= REG_NOTBOL;
>                         data += regmatch.rm_eo;
> -                       if (*data && regmatch.rm_so == regmatch.rm_eo)
> +                       sz -= regmatch.rm_eo;
> +                       if (*data && regmatch.rm_so == regmatch.rm_eo) {
>                                 data++;
> +                               sz--;
> +                       }
>                         cnt++;
>                 }
>
> diff --git a/t/t4062-diff-pickaxe.sh b/t/t4062-diff-pickaxe.sh
> index f0bf50bda..7c4903f49 100755
> --- a/t/t4062-diff-pickaxe.sh
> +++ b/t/t4062-diff-pickaxe.sh
> @@ -19,4 +19,9 @@ test_expect_success '-G matches' '
>         test 4096-zeroes.txt = "$(cat out)"
>  '
>
> +test_expect_success '-S --pickaxe-regex' '
> +       git diff --name-only -S0 --pickaxe-regex HEAD^ >out &&
> +       verbose test 4096-zeroes.txt = "$(cat out)"
> +'
> +
>  test_done

Hang on, this new test does fail because of a segfault _with_ the fix
on Travis 64bit Linux and OSX builds.

Oh, well.

  reply	other threads:[~2017-03-18 17:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 15:12 [PATCH] pickaxe: fix segfault with '-S<...> --pickaxe-regex' SZEDER Gábor
2017-03-18 17:45 ` SZEDER Gábor [this message]
2017-03-18 18:24   ` [PATCHv2] " SZEDER Gábor
2017-03-21 11:46     ` Johannes Schindelin
2017-03-18 18:58 ` [PATCH] " Junio C Hamano
2017-03-18 19:17   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM0VKjknLpCyQfY+ie3sfGemwhyad3Tk-5fHdeTSz2-WTw7NoQ@mail.gmail.com \
    --to=szeder.dev@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).