[postgis-users] Infinite loop in st_intersects - because of incorrect data out of st_transform?

Magnus Hagander magnus at hagander.net
Tue Mar 8 01:16:20 PST 2011

On Mon, Feb 28, 2011 at 16:35, Mark Cave-Ayland
<mark.cave-ayland at siriusit.co.uk> wrote:
> On 28/02/11 15:18, Magnus Hagander wrote:
>> Hi!
>> Running the following query locks up postgis completely (in
>> geos::algorithm::RobustDeterminant):
>> SELECT st_intersects(somegeometry,
>> '0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540'::geometry)
>> I believe this is because there are infinite values in that geometry:
>> # select
>> ST_AsText('0103000020E61000000100000005000000737979F3DDCC2CC0F92154F9E7534540000000000000F07F000000000000F07F8F806E993F7E55C0304B29FFEA8554400634E8D1DD424540B5FEE6A37FCD4540737979F3DDCC2CC0F92154F9E7534540'::geometry);
>>   st_astext
>> ---------------------------------------------------------------------------------------------------------------------------------------------------------------
>>  POLYGON((-14.4001308522972 42.6555167828373,inf inf,-85.9726317957995
>> 82.0924680617579,42.5223944076352 43.6054577711015,-14.4001308522972
>> 42.6555167828373))
>> (1 row)
>> ISTM that this should either be rejected as an invalid geometry, or at
>> least not hang....
> Hi Magnus,
> Hmmmm - I can definitely reproduce this on trunk with GEOS 3.2 series. The
> backtrace from inside GEOS looks like this:

Since nobody appears to be too interested in producing a quick fix in
geos, attached is a patch that puts in an *ugly* workaround in
PostGIS, that simply rejects the infinite values higher up in the
stack. I don't consider this a long-term fix, but it at least causes
an error instead of getting stuck in an infinite loop that can only be
terminated with kill -9... So pending a solution in geos, I would
suggest this workaround (or something better located written by
someone who actually know the postgis code better than me) be put in.
The way it is now, any application that allows the user to specify
input that could generate such a geometry could trivially
denial-of-service any postgis site...

 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: infinite_intersects_workaround.patch
Type: text/x-patch
Size: 996 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110308/7cd6400e/attachment.bin>

More information about the postgis-users mailing list