t7812: test PCRE2 whitespace bug

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>

René Scharfe committed Apr 8, 2022 at 18:21 UTC c36c27e75cb367e16392cc8fc4fd3f311126ab59
1 file changed +10
t/t7812-grep-icase-non-ascii.sh
+10
@@ -4,6 +4,10 @@ test_description='grep icase on non-English locales'
4
5 . ./lib-gettext.sh
6
7 +doalarm () {
8 + perl -e 'alarm shift; exec @ARGV' -- "$@"
9 +}
10 +
11 test_expect_success GETTEXT_LOCALE 'setup' '
12 test_write_lines "TILRAUN: Halló Heimur!" >file &&
13 git add file &&
@@ -139,4 +143,10 @@ test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep non-literal ASCII fro
143 test_cmp expected actual
144 '
145
146 +test_expect_success GETTEXT_LOCALE,LIBPCRE2 'PCRE v2: grep avoid endless loop bug' '
147 + echo " Halló" >leading-whitespace &&
148 + git add leading-whitespace &&
149 + doalarm 1 git grep --perl-regexp "^\s" leading-whitespace
150 +'
151 +
152 test_done