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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org, Aleksander Alekseev <aleksander@timescale.com>, dhyan@nataraj.su
Date: 2024-11-16T16:02:58Z
Lists: pgsql-bugs
Alexander Lakhin <exclusion@gmail.com> writes:
> Please look at the hornet's failure on processing a test query added here:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hornet&dt=2024-11-15%2023%3A49%3A38

Hmm... for the archives' sake, that looks like

 select * from test_regex('[^\\d\\D]', '0123456789abc*', 'ILPE');
-                        test_regex                       
- --------------------------------------------------------
-  {0,REG_UBBS,REG_UNONPOSIX,REG_ULOCALE,REG_UIMPOSSIBLE}
- (1 row)
- 
+ ERROR:  invalid regular expression: out of memory
  -- check char classes' handling of newlines

I'm not sure what to make of it.  That regex shouldn't consume very
much memory.  To confirm that, I stepped through it and found that
newstate() is reached 14 times and newarc() 35 times.  That's a
pretty tiny amount of memory, and there are other regexps in the
tests that are far larger.

Moreover, no other animal has shown this, including hornet itself
on the v16 branch.  (It's only run this test in v15 and v16 so far,
so that's not a lot of data points.)

I'm inclined to guess this was some weird momentary glitch.  If it
reproduces then I'll look closer.

			regards, tom lane



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.