git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t7812: expect failure for grep -i with invalid UTF-8 data

From
Todd Zullinger <tmz@pobox.com>
Date
Dec 1, 2019, 18:32 UTC
Message-ID
<20191201183203.GC17681@pobox.com>
In-Reply-To
<xmqqo8wsypit.fsf@gitster-ct.c.googlers.com>
Hi,
Junio C Hamano wrote:
Show 14 quoted lines
> Andreas Schwab <schwab@linux-m68k.org> writes:
> 
>> On Nov 29 2019, Todd Zullinger wrote:
>>
>>> When the 'grep with invalid UTF-8 data' tests were added/adjusted in
>>> 8a5999838e (grep: stess test PCRE v2 on invalid UTF-8 data, 2019-07-26)
>>> and 870eea8166 (grep: do not enter PCRE2_UTF mode on fixed matching,
>>> 2019-07-26) they lacked a redirect which caused them to falsely succeed
>>> on most architectures.  They failed on big-endian arches where the test
>>> never reached the portion which was missing the redirect.
>>
>> It's not about big vs little endian, it's only about JIT vs non-JIT.
> 
> So, which one of JIT / non-JIT sides did the test fail unexpectedly?
On s390x, the initial:
    test_might_fail git grep -hi "Æ" invalid-0x80 >actual

fails to produce any output in actual, but since we use test_might_fail, the test happily continues to:

    test_cmp expected actual
which fails.
The test output from and s390x build:
    expecting success of 7812.11 'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i':
        test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
        test_cmp expected actual &&
        test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 &&
        test_cmp expected actual
    ++ test_might_fail git grep -hi Æ invalid-0x80
    ++ test_must_fail ok=success git grep -hi Æ invalid-0x80
    ++ case "$1" in
    ++ _test_ok=success
    ++ shift
    ++ git grep -hi Æ invalid-0x80
    fatal: pcre2_match failed with error code -22: UTF-8 error: isolated byte with 0x80 bit set
    ++ exit_code=128
    ++ test 128 -eq 0
    ++ test_match_signal 13 128
    ++ test 128 = 141
    ++ test 128 = 269
    ++ return 1
    ++ test 128 -gt 129
    ++ test 128 -eq 127
    ++ test 128 -eq 126
    ++ return 0
    ++ test_cmp expected actual
    ++ diff -u expected actual
    --- expected    2019-10-19 21:56:08.634252012 +0000
    +++ actual      2019-10-19 21:56:08.714252012 +0000
    @@ -1 +0,0 @@
    -ævar
    error: last command exited with $?=1
    not ok 11 - PCRE v2: grep non-ASCII from invalid UTF-8 data with -i
    #
    #               test_might_fail git grep -hi "Æ" invalid-0x80 >actual &&
    #               test_cmp expected actual &&
    #               test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 &&
    #               test_cmp expected actual
    #
    # failed 1 among 11 test(s)

After Andreas' missing redirect fix, that still fails on s390x (not surprisingly). But now systems with JIT enabled fail at:

    test_must_fail git grep -hi "(*NO_JIT)Æ" invalid-0x80 >actual &&
    test_cmp expected actual

Though we say that the command must fail, so we shouldn't be surprised that 'expect' and 'actual' don't match. It would be more surprising if they did. :)

> Should I do s/on big-endian arches/with PCRE with JIT disabled/
> while queuing the patch?

Here's how I changed the commit message locally. I was going to wait a day or so for any other feedback on the actual test changes, being a holiday weekend in the US (and more generally a weekend).

1:  d9aeaf0c98 ! 1:  d0c083db78 t7812: expect failure for grep -i with invalid UTF-8 data
    @@ Commit message
         8a5999838e (grep: stess test PCRE v2 on invalid UTF-8 data, 2019-07-26)
         and 870eea8166 (grep: do not enter PCRE2_UTF mode on fixed matching,
         2019-07-26) they lacked a redirect which caused them to falsely succeed
    -    on most architectures.  They failed on big-endian arches where the test
    -    never reached the portion which was missing the redirect.
    +    on most systems.  The 'grep -i' test failed on systems where JIT was
    +    disabled as it never reached the portion which was missing the redirect.
     
    -    A recent patch add the missing redirect and exposed the fact that the
    -    'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' test fails on
    -    all architectures.
    +    A recent patch added the missing redirect and exposed the fact that the
    +    'PCRE v2: grep non-ASCII from invalid UTF-8 data with -i' test fails
    +    regardless of whether JIT is enabled.
     
         Based on the final paragraph in in 870eea8166:

Thanks for pointing out the proper reasoning to use in the commit message Andreas. I hadn't looked at the Fedora pcre2 package to see that it explicitly disables JIT on s390x.

I'm not sure if s390x is supported upstream or not -- it doesn't appear to have a specific entry in the sljit config header¹, so it seems likely it's not well-tested at the least. (Not that any of that is our concern here.)

¹ https://github.com/zherczeg/sljit/blob/master/sljit_src/sljitConfigInternal.h
Thanks for the follow-up Junio.
-- 
Todd
Previous: Andreas SchwabNext: Junio C Hamano
Message 30 of 70 in “grep: use custom JIT stack with pcre2”
  1. grep: use custom JIT stack with pcre2Carlo Marcelo Arenas Belón, Jul 21, 2019
  2. 0/3 grep: PCRE JIT fixesÆvar Arnfjörð Bjarmason, Jul 24, 2019
  3. Junio C HamanoJul 24, 2019
  4. Ævar Arnfjörð BjarmasonJul 24, 2019
  5. 1/8 grep: remove overly paranoid BUG(...) codeÆvar Arnfjörð Bjarmason, Jul 26, 2019
  6. 2/8 grep: stop "using" a custom JIT stack with PCRE v2Ævar Arnfjörð Bjarmason, Jul 26, 2019
  7. Carlo ArenasJul 29, 2019
  8. 3/8 grep: stop using a custom JIT stack with PCRE v1Ævar Arnfjörð Bjarmason, Jul 26, 2019
  9. Carlo ArenasJul 29, 2019
  10. 4/8 grep: consistently use "p->fixed" in compile_regexp()Ævar Arnfjörð Bjarmason, Jul 26, 2019
  11. Carlo ArenasJul 29, 2019
  12. Ævar Arnfjörð BjarmasonJul 29, 2019
  13. Ævar Arnfjörð BjarmasonJul 29, 2019
  14. Junio C HamanoJul 29, 2019
  15. 5/8 grep: create a "is_fixed" member in "grep_pat"Ævar Arnfjörð Bjarmason, Jul 26, 2019
  16. 7/8 grep: do not enter PCRE2_UTF mode on fixed matchingÆvar Arnfjörð Bjarmason, Jul 26, 2019
  17. Junio C HamanoJul 26, 2019
  18. 6/8 grep: stess test PCRE v2 on invalid UTF-8 dataÆvar Arnfjörð Bjarmason, Jul 26, 2019
  19. Junio C HamanoJul 26, 2019
  20. Ævar Arnfjörð BjarmasonJul 26, 2019
  21. Carlo ArenasJul 29, 2019
  22. t7812: add missing redirectsAndreas Schwab, Nov 26, 2019
  23. Johannes SchindelinNov 26, 2019
  24. Andreas SchwabNov 26, 2019
  25. Jeff KingNov 27, 2019
  26. t7812: expect failure for grep -i with invalid UTF-8 dataTodd Zullinger, Nov 30, 2019
  27. Andreas SchwabNov 30, 2019
  28. Junio C HamanoDec 1, 2019
  29. Andreas SchwabDec 1, 2019
  30. Todd ZullingerDec 1, 2019
  31. Junio C HamanoDec 2, 2019
  32. 0/8 grep: PCRE JIT fixes + ab/no-kwset fixÆvar Arnfjörð Bjarmason, Jul 26, 2019
  33. Junio C HamanoJul 26, 2019
  34. Ævar Arnfjörð BjarmasonJul 29, 2019
  35. Junio C HamanoJul 29, 2019
  36. 8/8 grep: optimistically use PCRE2_MATCH_INVALID_UTFÆvar Arnfjörð Bjarmason, Jul 26, 2019
  37. Junio C HamanoJul 26, 2019
  38. Ævar Arnfjörð BjarmasonJul 26, 2019
  39. Ævar Arnfjörð BjarmasonJul 26, 2019
  40. 0/4 grep: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  41. 1/2 grep/pcre2 tests: don't rely on invalid UTF-8 data testÆvar Arnfjörð Bjarmason, Jan 24, 2021
  42. 2/2 grep/pcre2: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  43. Ramsay JonesJan 24, 2021
  44. Ramsay JonesJan 24, 2021
  45. Ævar Arnfjörð BjarmasonJan 24, 2021
  46. Ramsay JonesJan 24, 2021
  47. Ævar Arnfjörð BjarmasonJan 24, 2021
  48. 0/2 grep: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  49. 0/2 grep: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  50. 1/2 grep/pcre2 tests: don't rely on invalid UTF-8 data testÆvar Arnfjörð Bjarmason, Jan 24, 2021
  51. 2/2 grep/pcre2: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  52. 1/4 grep/pcre2 tests: don't rely on invalid UTF-8 data testÆvar Arnfjörð Bjarmason, Jan 24, 2021
  53. 4/4 grep/pcre2: better support invalid UTF-8 haystacksÆvar Arnfjörð Bjarmason, Jan 24, 2021
  54. 3/4 grep/pcre2: further simplify boolean spaghettiÆvar Arnfjörð Bjarmason, Jan 24, 2021
  55. 2/4 grep/pcre2: simplify boolean spaghettiÆvar Arnfjörð Bjarmason, Jan 24, 2021
  56. Junio C HamanoJan 24, 2021
  57. Johannes SixtJan 24, 2021
  58. 2/3 grep: stop "using" a custom JIT stack with PCRE v2Ævar Arnfjörð Bjarmason, Jul 24, 2019
  59. Junio C HamanoJul 24, 2019
  60. Ævar Arnfjörð BjarmasonJul 24, 2019
  61. Carlo ArenasJul 25, 2019
  62. 1/3 grep: remove overly paranoid BUG(...) codeÆvar Arnfjörð Bjarmason, Jul 24, 2019
  63. 3/3 grep: stop using a custom JIT stack with PCRE v1Ævar Arnfjörð Bjarmason, Jul 24, 2019
  64. Carlo ArenasJul 26, 2019
  65. Ævar Arnfjörð BjarmasonJul 26, 2019
  66. Carlo ArenasJul 26, 2019
  67. Ævar Arnfjörð BjarmasonJul 26, 2019
  68. 0/2 PCRE1 cleanupCarlo Marcelo Arenas Belón, Jul 26, 2019
  69. 1/2 grep: make sure NO_LIBPCRE1_JIT disable JIT in PCRE1Carlo Marcelo Arenas Belón, Jul 26, 2019
  70. 2/2 grep: refactor and simplify PCRE1 supportCarlo Marcelo Arenas Belón, Jul 26, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.