Re: BUG #18708: regex problem: (?:[^\d\D]){0} asserts with "lp->nouts == 0 && rp->nins == 0"

Aleksander Alekseev <aleksander@timescale.com>

From: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-bugs@lists.postgresql.org
Cc: dhyan@nataraj.su
Date: 2024-11-14T15:08:52Z
Lists: pgsql-bugs
Hi,

> I wonder if the Assert is just wrong or if it's more complicated than that.
>
> For the record:
>
> ([^\d\D]){0} - OK
> (?:[^\d\D]){1} - OK
> (?:[^\D]){0} - OK
> (?:[^\d]){0} - OK
> '(?:[^\d\D]){0}' - FAIL

Well, removing the assert helps, and the regex seems to work correctly
after that.

This however is almost certainly not a correct fix (the assert is
right about lp->nouts == 0 it's only unhappy about rp->nins != 0) and
a second opinion is certainly needed since I'm looking at
src/backend/regex/regc_nfa.c for the first time in my life :)

-- 
Best regards,
Aleksander Alekseev



Commits

  1. Fix recently-exposed portability issue in regex optimization.

  2. Avoid assertion due to disconnected NFA sub-graphs in regex parsing.

  3. Fix recovery conflict SIGUSR1 handling.

  4. Redesign interrupt/cancel API for regex engine.

  5. Use MemoryContext API for regex memory management.

  6. Invent "rainbow" arcs within the regex engine.