Lists: | pgsql-hackers |
---|
From: | Marc Mamin <M(dot)Mamin(at)intershop(dot)de> |
---|---|
To: | "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | invalid regexp crashes the server on windows or 9.3 |
Date: | 2013-09-25 07:33:02 |
Message-ID: | B6F6FD62F2624C4C9916AC0175D56D880CE20F8A@jenmbs01.ad.intershop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
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
From: | "Erik Rijkers" <er(at)xs4all(dot)nl> |
---|---|
To: | "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de> |
Cc: | "'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 07:54:11 |
Message-ID: | 07fe9ef4f29f205d73e9ff7556e64e08.squirrel@webmail.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
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
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 |
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