Opened 11 years ago

Closed 11 years ago

#649 closed defect (fixed)

ST_Snap crashes on some inputs

Reported by: robe Owned by: geos-devel@…
Priority: major Milestone: 3.4.1
Component: Default Version: 3.4.0
Severity: Unassigned Keywords:
Cc: history

Description

This was logged as an issue in PostGIS at:

http://trac.osgeo.org/postgis/ticket/2426

Doesn't seem to be an issue in 3.3

SELECT ST_Snap('POLYGON Z ((-71.1319 42.2512 0,-71.1318 42.2511 20,-71.1317 42.2511 -20,-71.1317 42.251 5,-71.1317 42.2509 4,-71.132 42.2511 6,-71.1319 42.2512 30))'::geometry, 'GEOMETRYCOLLECTION Z (MULTIPOLYGON Z (((-71.0821 42.3036 2,-71.0822 42.3036 2,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2))),POLYGON Z ((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 1,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1)))'::geometry, 0.5)

Just in case that doesn't crash for you, the original I was trying it from was a statement generated by the PostGIS garden monkey script.

{{{SELECT ST_Snap(foo1.the_geom, foo2.the_geom, 0.5) As result, ST_AsText(foo1.the_geom) As ref1_geom, ST_AsText(foo2.the_geom) As ref2_geom

FROM ((SELECT geom As the_geom

FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2503 1,-71.132 42.2502 3,-71.1323 42.2504 -2,-71.1322 42.2505 1,-71.1319 42.2503 0))') ),

( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2512 0,-71.1318 42.2511 20,-71.1317 42.2511 -20,-71.1317 42.251 5,-71.1317 42.2509 4,-71.132 42.2511 6,-71.1319 42.2512 30))') )

) As g(geom))) As foo1 CROSS JOIN ((SELECT ST_Collect(geom) As the_geom FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.0822 42.3036 2,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') ),

( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 1,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1))') ) ) As g(geom) CROSS JOIN generate_series(1,3) As i GROUP BY i )) As foo2 LIMIT 2;

}}}

Change History (9)

comment:1 by robe, 11 years ago

SELECT ST_Snap(foo1.the_geom, foo2.the_geom, 0.5) As result, ST_AsText(foo1.the_geom) As ref1_geom, ST_AsText(foo2.the_geom) As ref2_geom
	FROM ((SELECT geom  As the_geom
FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2503 1,-71.132 42.2502 3,-71.1323 42.2504 -2,-71.1322 42.2505 1,-71.1319 42.2503 0))') ),
	( ST_GeomFromEWKT('SRID=4326;POLYGONM((-71.1319 42.2512 0,-71.1318 42.2511 20,-71.1317 42.2511 -20,-71.1317 42.251 5,-71.1317 42.2509 4,-71.132 42.2511 6,-71.1319 42.2512 30))') )
		)	As g(geom))) As foo1 CROSS JOIN ((SELECT ST_Collect(geom)  As the_geom
		FROM (VALUES ( ST_GeomFromEWKT('SRID=4326;MULTIPOLYGON(((-71.0821 42.3036 2,-71.0822 42.3036 2,-71.082 42.3038 2,-71.0819 42.3037 2,-71.0821 42.3036 2)))') ),
	( ST_GeomFromEWKT('SRID=4326;POLYGON((-71.1261 42.2703 1,-71.1257 42.2703 1,-71.1257 42.2701 1,-71.126 42.2701 1,-71.1261 42.2702 1,-71.1261 42.2703 1))') ) ) As g(geom) CROSS JOIN generate_series(1,3) As i GROUP BY i )) As foo2 LIMIT 2;

comment:2 by strk, 11 years ago

Crashes for me too

comment:3 by strk, 11 years ago

Can you reduce this down to the 2 geometries and 1 double inputs to GEOSSnap ?

comment:4 by strk, 11 years ago

Resolution: invalid
Status: newclosed

I can't reproduce any problem with GEOS and that input.

comment:5 by strk, 11 years ago

GEOS answer (valgrind clean):

POLYGON ((-71.0819 42.3037, -71.13200000000001 42.2502, -71.1323 42.2504, -71.126 42.2701, -71.12609999999999 42.2702, -71.12609999999999 42.2703, -71.12569999999999 42.2701, -71.12569999999999 42.2703, -71.0822 42.3036, -71.0821 42.3036, -71.08199999999999 42.3038, -71.0819 42.3037))

comment:6 by strk, 11 years ago

Resolution: invalid
Status: closedreopened

Reopening as further info from the PostGIS ticket suggest there's actually a bug in LineStringSnapper.cpp line 349

comment:7 by strk, 11 years ago

Bingo, the actual offending input is:

A: LINESTRING(-71.1317 42.2511,-71.1317 42.251,-71.1317 42.2509)
B: MULTIPOINT(-71.1261 42.2703,-71.1257 42.2703,-71.1261 42.2702)

Assertion failing:

snap/LineStringSnapper.cpp:349: void geos::operation::overlay::snap::LineStringSnapper::snapSegments(geos::geom::CoordinateList&, const ConstVect&): Assertion `pf != 0.0' failed.

comment:8 by strk, 11 years ago

Simplified input for A:

A: LINESTRING(-71.1317 42.2511,-71.1317 42.2509)

comment:9 by strk, 11 years ago

Cc: history added
Resolution: fixed
Status: reopenedclosed

r3885 in trunk, r3886 in 3.4 branch (3.4.1), r3887 in 3.3 branch (3.3.9).

NOTE: the _new_ snapping code was only ever released in 3.4.0, the version in 3.3 branch was never released yet

Note: See TracTickets for help on using tickets.