Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#112 closed defect (fixed)

ST_CurveToLine sometimes crashes server

Reported by: robe Owned by: pramsey
Priority: medium Milestone: PostGIS 1.4.0
Component: postgis Version: 1.3.X
Keywords: Cc:

Description (last modified by robe)

What steps will reproduce the problem? 1.

SELECT 'ST_CurveToLine GCSet3D: Start Testing GEOMETRYCOLLECTION';

BEGIN; SELECT ST_AsEWKT(ST_CurveToLine(foo1.the_geom))

FROM ((SELECT

ST_Collect(ST_Collect(ST_SetSRID(ST_MakePoint(i,j,m),4326),ST_SetSRID(ST_MakePolygon(ST_AddPoint(ST_AddPoint(ST_MakeLine(ST_MakePoint(i+m,j,m),ST_MakePoint(j+m,i-m,m)),ST_MakePoint(i,j,m)),ST_MakePointM(i+m,j,m))),4326)))

As the_geom

FROM generate_series(-10,50,20) As i

CROSS JOIN generate_series(50,70, 20) As j CROSS JOIN generate_series(1,2) As m GROUP BY m)) As foo1;

COMMIT; SELECT 'ST_CurveToLine GCSet3D: End Testing GEOMETRYCOLLECTION';

What is the expected output? It should do nothing and just return what I input since input contains no curves.

What do you see instead? psql:torturetest.sql:157312: server closed the connection unexpectedly

This probably means the server terminated abnormally before or while processing the request.

psql:torturetest.sql:157312: connection to server was lost

Haven't test on 1.3 but assume same issue exists

Change History (13)

comment:1 by mcayland, 15 years ago

Here's the preliminary backtrace:

(gdb) bt #0 0x000000000067c68a in pfree () #1 0x00007ffa773e502b in lwgeom_release (lwgeom=0xb7f420) at lwgeom.c:332 #2 0x00007ffa773df079 in LWGEOM_curve_segmentize () from /home/pg83/rel-8.3.5/lib/postgresql/postgis-1.4.so #3 0x00000000005294bd in ExecMakeFunctionResult () #4 0x0000000000527615 in ExecEvalFuncArgs () #5 0x0000000000529433 in ExecMakeFunctionResult () #6 0x00000000005273ce in ExecProject () #7 0x000000000052d1df in ExecScan () #8 0x00000000005268e8 in ExecProcNode () #9 0x0000000000524905 in ExecutorRun () #10 0x00000000005be5a0 in PortalRunSelect () #11 0x00000000005bfc09 in PortalRun () #12 0x00000000005baeac in exec_simple_query () #13 0x00000000005bc3d7 in PostgresMain () #14 0x00000000005907b2 in ServerLoop () #15 0x0000000000591494 in PostmasterMain () #16 0x0000000000546b48 in main () (gdb) frame 1 #1 0x00007ffa773e502b in lwgeom_release (lwgeom=0xb7f420) at lwgeom.c:332 332 lwfree(lwgeom→bbox); Current language: auto; currently c (gdb)

I suspect it's probably related to some geometries having bboxs and some not…

ATB,

Mark.

comment:2 by mleslie, 15 years ago

Distilled the test case down to:

SELECT ST_CurveToLine('GEOMETRYCOLLECTION(POINT(-10 50))'::geometry);

Effects both 1.3 branch and trunk.

comment:3 by mcayland, 15 years ago

Arrgh! I've worked out what's happening here: basically pglwgeom_serialize() alters its input geometry which should be a total no-no. The fix should be to remove this horrible piece of code from pglwgeom_serialize:

#if POSTGIS_AUTOCACHE_BBOX

if ( ! in→bbox && is_worth_caching_lwgeom_bbox(in) ) {

lwgeom_addBBOX(in);

}

#endif

and then go around the rest of the codebase fixing up any callers that require it.

ATB,

Mark.

comment:4 by pramsey, 15 years ago

Fixed in trunk at r3807. Fixed in 1.3 at r3808.

comment:5 by robe, 15 years ago

I renabled this test in torture script and doesn't seem to crash anymore. Haven't tested on 1.3 though. I'll test that tomorrow.

comment:6 by pramsey, 15 years ago

<i>(No comment was entered for this change.)</i>

comment:7 by pramsey, 15 years ago

No news is good news.

comment:8 by robe, 15 years ago

Description: modified (diff)
Resolution: fixed
Status: closedreopened

Well I haven't tested this on 1.3.6 but crashes server on 1.3.5 production and 1.4.0 SVN (at least on Windows).

SELECT ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(4 4,4 5,4 8)'))

comment:9 by robe, 15 years ago

Milestone: postgis 1.3.6postgis 1.4.1

Pushing this to 1.4.1 - I don't think its worthwhile holding up 1.3.6 for this and the original problem with teh original test cases works now.

comment:10 by robe, 15 years ago

This one by the way is still an open issue. Crashes server.

comment:11 by mcayland, 15 years ago

Milestone: postgis 1.4.1postgis 1.4.0

Another curve crasher that hasn't been resolved by Mark's patch :( Let's get this resolved ASAP…

comment:12 by mcayland, 15 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in 1.4 in r4271 and trunk in r4272. Colinearity in the circle points was detected, however the check was missing for the NULL pointer being returned in this case. If the points are detected as colinear, then the current behaviour is to simply append the circle points to the LINESTRING as standard points.

Again, I don't feel the need to backpatch to 1.3 due to the existing curve-related bugs that won't get fixed in that branch.

ATB,

Mark.

comment:13 by robe, 15 years ago

Seems fine to me

Note: See TracTickets for help on using tickets.