Обсуждение: invalid regexp crashes the server on windows or 9.3
Hi,
This regexp call freezes with almost 100% CPU usage, so I guess it creates an infinite loop.
With Postgres 9.1 on Linux, I can kill the backend cleanly and get following message:
cic_db=# select regexp_matches ('aa bb aa ba baa x','(^((?!aa)))+','gx');
ERROR: invalid regular expression: nfa has too many states
on Windows and Postgres 9.3, I used the terminate icon from pgAdmin,
which resulted in a FATAL error, killed all other processes and finally stopped the server.
I guesss this is a windows issue, but we do not have a Postgres 9.3 installation on Linux yet, so that I can't test it.
here the log entries from widows 9.3:
2013-09-25 09:02:40 CEST LOG: Serverprozess (PID 5952) wurde durch Ausnahme 0xC00000FD beendet
2013-09-25 09:02:40 CEST DETAIL: Der fehlgeschlagene Prozess führte aus: select regexp_matches ('aa bb aa ba baa x','(^((?!aa)))+','gx')
2013-09-25 09:02:40 CEST TIPP: Sehen Sie die Beschreibung des Hexadezimalwerts in der C-Include-Datei „ntstatus.h“ nach.
2013-09-25 09:02:40 CEST LOG: aktive Serverprozesse werden abgebrochen
2013-09-25 09:02:40 CEST WARNUNG: breche Verbindung ab wegen Absturz eines anderen Serverprozesses
2013-09-25 09:02:40 CEST DETAIL: Der Postmaster hat diesen Serverprozess angewiesen, die aktuelle Transaktion zurückzurollen und die Sitzung zu beenden, weil ein anderer Serverprozess abnormal beendet wurde und möglicherweise das Shared Memory verfälscht hat.
2013-09-25 09:02:40 CEST TIPP: In einem Moment sollten Sie wieder mit der Datenbank verbinden und Ihren Befehl wiederholen können.
2013-09-25 09:02:40 CEST WARNUNG: breche Verbindung ab wegen Absturz eines anderen Serverprozesses
2013-09-25 09:02:40 CEST DETAIL: Der Postmaster hat diesen Serverprozess angewiesen, die aktuelle Transaktion zurückzurollen und die Sitzung zu beenden, weil ein anderer Serverprozess abnormal beendet wurde und möglicherweise das Shared Memory verfälscht hat.
2013-09-25 09:02:40 CEST TIPP: In einem Moment sollten Sie wieder mit der Datenbank verbinden und Ihren Befehl wiederholen können.
2013-09-25 09:02:40 CEST LOG: alle Serverprozesse beendet; initialisiere neu
2013-09-25 09:02:50 CEST FATAL: bereits bestehender Shared-Memory-Block wird noch benutzt
2013-09-25 09:02:50 CEST TIPP: Prüfen Sie, ob irgendwelche alten Serverprozesse noch laufen und beenden Sie diese.
translated:
exception 0xC00000FD stopped PID ,
check ntstatus.h for the description of the hexadecimal value
regards,
Marc Mamin
On Wed, September 25, 2013 09:33, Marc Mamin wrote:
> Hi,
>
> This regexp call freezes with almost 100% CPU usage, so I guess it creates an infinite loop.
>
> With Postgres 9.1 on Linux, I can kill the backend cleanly and get following message:
>
> cic_db=# select regexp_matches ('aa bb aa ba baa x','(^((?!aa)))+','gx');
> ERROR: invalid regular expression: nfa has too many states
>
> on Windows and Postgres 9.3, I used the terminate icon from pgAdmin,
> which resulted in a FATAL error, killed all other processes and finally stopped the server.
>
> I guesss this is a windows issue, but we do not have a Postgres 9.3 installation on Linux yet, so that I can't test
it.
>
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.
Erik Rijkers
"Erik Rijkers" <er@xs4all.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)
withthat
> 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