]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7812: test PCRE2 whitespace bug
authorRené Scharfe <l.s.r@web.de>
Fri, 8 Apr 2022 16:21:52 +0000 (18:21 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Apr 2022 16:42:09 +0000 (09:42 -0700)
Check if git grep works around the PCRE2 big fixed by their e0c6029
(Fix inifinite loop when a single byte newline is searched in JIT.,
2020-05-29), which affects version 10.35 and earlier.

Searching for leading whitespace also triggers the endless loop.
Set a one-second alarm to abort in case we do get hit by the bug, to
avoid having to wait forever for the test result.

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7812-grep-icase-non-ascii.sh

index 9047d665a1049195ec03b64504c973559a677c36..ac7be5471452a0a8b2123dc39be80caf3520e9db 100755 (executable)
@@ -4,6 +4,10 @@ test_description='grep icase on non-English locales'
 
 . ./lib-gettext.sh
 
+doalarm () {
+       perl -e 'alarm shift; exec @ARGV' -- "$@"
+}
+
 test_expect_success GETTEXT_LOCALE 'setup' '
        test_write_lines "TILRAUN: Halló Heimur!" >file &&
        git add file &&
@@ -139,4 +143,10 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII fro
        test_cmp expected actual
 '
 
+test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep avoid endless loop bug' '
+       echo " Halló" >leading-whitespace &&
+       git add leading-whitespace &&
+       doalarm 1 git grep --perl-regexp "^\s" leading-whitespace
+'
+
 test_done