[postgis-users] Postgis 1.5 core dumps on GEOSIntersects with side location conflict

Martin Davis mtnclimb at telus.net
Fri Sep 21 10:30:19 PDT 2012


This occurs because the geometries are invalid, and the current 
intersects algorithm used in JTS/GEOS has kittens when invalid 
geometries are used as input.  The core dump thing is unfortunate (and 
obviously got fixed in later versions).

You might say "surely this shouldn't cause such a serious error", and 
I'd agree.  Probably what should happen in the case of invalid 
geometries input to predicates is that they return a (possibly bogus) 
result.  You might then say "but obviously they do intersect, so why 
can't the result be correct?", and in this case I'd also agree.  The 
intersects algorithm could be enhanced to detect intersection correctly 
in almost all cases, valid or not.  (Some of the other predicates might 
not be so tolerant - but still a "best effort" strategy would be nicer 
than outright failure).

But that's all work for the future (and get in touch if you have funding 
to offer!)

For now, all you can do is to check validity before running the 
ST_intersects function in some way. The nicest way to do this would be 
to create a new function which does the validity check internally.  And 
that function could also be enhanced to do some other kinds of 
intersection checks, to try and detect intersection for any inputs.  For 
instance, in this case ST_intersects could be run safely on the geometry 
boundary linework, and will then report the correct answer.  This could 
be supplemented with some point-in-polygon checks to catch the situation 
of disjoint boundaries.  Alternatively, if invalid polygons are detected 
the buffer(0) trick could be used to try and clean them.


On 9/20/2012 7:37 AM, Adam wrote:
> Running this query against Postgis 1.5 causes a core dump:
> SELECT ST_intersects(
>    geomfromtext('POLYGON((31.904296875 67.32421875,14.58984375 
> 67.32421875,12.744140625 65.830078125,33.75 66.09375,31.904296875 
> 67.236328125,31.81640625 67.32421875,31.904296875 67.32421875))', 4326),
>    geomfromtext('POLYGON((31.904296875 67.32421875,14.58984375 
> 67.32421875,12.744140625 65.830078125,33.75 66.09375,31.904296875 
> 67.236328125,31.81640625 67.32421875,31.904296875 67.32421875))', 4326)
> );
>
> Running against Postgis 2.0 gives the following error (much preferred 
> to get an error than a core dump!):
> ERROR:  GEOSIntersects: TopologyException: side location conflict at 
> 31.81640625 67.32421875
> CONTEXT:  SQL function "st_intersects" statement 1
>
> Both are using geos version: '3.3.5-CAPI-1.7.5'.
>
> Unfortunately upgrading to Postgis 2 is not an option for us.
> Our platform is Solaris 10 x86 using 64 bit builds.
>
> From dbx the core file shows:
>   [1] 0x1b408d(0x1, 0x1, 0x474e5543432b2b00, 0xbe0170, 
> 0xfffffd7fffdf8880, 0x1b408d), at 0x1b408d
>   [2] _Unwind_RaiseException_Body(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 
> 0xfffffd7ffec416bc
>   [3] _SUNW_Unwind_RaiseException(0x0, 0x0, 0x0, 0x0, 0x0, 0x0), at 
> 0xfffffd7ffec418a9
>   [4] __cxa_throw(obj = (nil), tinfo = (nil), dest = (nil)), line 75 
> in "eh_throw.cc"
>   [5] geos::geomgraph::EdgeEndStar::propagateSideLabels(this = 
> 0xfffffd7ffe6e2a00, geomIndex = 0), line 69 in "new_allocator.h"
>   [6] 
> _ZN4geos9geomgraph11EdgeEndStar16computeLabellingEPSt6vectorIPNS0_13GeometryGraphESaIS4_EE(this 
> = 0x91bc10, geomGraph = 0xfffffd7fffdf8e18), line 88 in "EdgeEndStar.cpp"
>   [7] geos::operation::relate::RelateComputer::labelNodeEdges(this = 
> 0xfffffd7fffdf8e30), line 327 in "RelateComputer.cpp"
>   [8] geos::operation::relate::RelateComputer::computeIM(this = 
> 0xfffffd7fffdf8e30), line 131 in "RelateComputer.cpp"
>   [9] geos::operation::relate::RelateOp::relate(a = (nil), b = (nil)), 
> line 43 in "RelateOp.cpp"
>   [10] geos::geom::Geometry::intersects(this = 0x91b598, g = 
> 0x91b638), line 191 in "memory"
>   [11] GEOSIntersects_r(extHandle = 0x91d100, g1 = (nil), g2 = (nil)), 
> line 351 in "geos_ts_c.cpp"
>   [12] GEOSIntersects(g1 = (nil), g2 = (nil)), line 139 in "geos_c.cpp"
>   [13] intersects(fcinfo = 0xfffffd7fffdf9110), line 2322 in 
> "lwgeom_geos.c"
>   [14] ExecMakeFunctionResult(fcache = 0xfffffd7fffdf90d0, econtext = 
> 0xbd5740, isNull = 0xbd6c28 "", isDone = (nil)), at 0x5a9d88
>   [15] ExecEvalAnd(andExpr = (nil), econtext = 0xbd5740, isNull = 
> 0xbd6c28 "", isDone = (nil)), at 0x5aaf23
>   [16] ExecProject(projInfo = 0xbd6c40, isDone = 0xfffffd7fffdf95bc), 
> at 0x5ae659
>   [17] ExecResult(node = 0xbd5630), at 0x5ba7d0
>   [18] ExecProcNode(node = 0xbd5630), at 0x5a77ec
>   [19] standard_ExecutorRun(queryDesc = 0xbcd2e8, direction = 
> ForwardScanDirection, count = 1), at 0x5a550c
>   [20] fmgr_sql(fcinfo = 0xfffffd7fffdf9880), at 0x5b1529
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2012.0.2221 / Virus Database: 2441/5281 - Release Date: 09/20/12
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120921/75616455/attachment.html>


More information about the postgis-users mailing list