Subject: bug#65726: 29.1.50; Crash in regexp engine

From: Mattias Engdegård <[email-masked]>
Date: Sat, 9 Sep 2023 18:34:42 +0200

9 sep. 2023 kl. 17.55 skrev Stefan Monnier <[email-masked]>:

> My patch didn't include the assertion :-)

Oh, I thought you meant the eassert (p2 >= done); added at the start of mutually_exclusive_aux. Sorry about the confusion.
Anyway, disassembling the regexp makes it clear why:

Disassembly of regexp "\\`[^ ]+\\( [^ ]+\\)*\\'"

    0  begbuf
    1  charset-not [ ]
    8  on-failure-jump-smart to 21
   11  charset-not [ ]
   18  jump to 8
   21  on-failure-jump to 54
   24  start-memory group 1
   26  exact " "
   29  charset-not [ ]
   36  on-failure-jump-smart to 49
   39  charset-not [ ]
   46  jump to 36
   49  stop-memory group 1
   51  jump to 21
   54  endbuf
   55  succeed

which unless I'm mistaken we can condense to:

Disassembly of regexp "\\(?:ba*\\)*"

    0  on-failure-jump to 18
    3  exact "b"
    6  on-failure-jump-smart to 15
    9  exact "a"
   12  jump to 6
   15  jump to 0
   18  succeed

so yes, we may need to remember where we've been. (At this point someone will inevitably point out a helpful invariant that is obvious in hindsight. This is just my cunning attempt at making that happen.)