Re: invalid regexp crashes the server on windows or 9.3

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Erik Rijkers" <er(at)xs4all(dot)nl>
Cc: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: invalid regexp crashes the server on windows or 9.3
Date: 2013-09-25 13:51:26
Message-ID: 26372.1380117086@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Erik Rijkers" <er(at)xs4all(dot)nl> writes:
> On Wed, September 25, 2013 09:33, Marc Mamin wrote:
>> This regexp call freezes with almost 100% CPU usage, so I guess it creates an infinite loop.
>> cic_db=# select regexp_matches ('aa bb aa ba baa x','(^((?!aa)))+','gx');

I poked into this a bit and decided that it's a variant of a problem we've
seen before. I filed a report with the Tcl crew to see if they have any
opinion about it:
https://core.tcl.tk/tcl/tktview?name=8f245009b0
but prior experience suggests they won't be a lot of help.

> On 9.3 and 9.4devel, on linux (centos 6.4), that statement / regex returns after ~2 minutes (on a modest desktop) with that
> same error, but not crashing.

Yeah, it should in principle fail eventually with a too-many-states error,
since the loop is creating more NFA states than it deletes. But on a Mac
laptop with an assert-enabled PG build, I got tired of waiting for that
after about an hour ...

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-09-25 14:52:47 Re: Freezing without write I/O
Previous Message Peter Eisentraut 2013-09-25 13:25:54 Re: Cube extension kNN support