Opened 9 years ago

Closed 9 years ago

#3256 closed defect (fixed)

ST_3DDistance sfcgal garden crash on malformed polygons

Reported by: robe Owned by: colivier
Priority: high Milestone: PostGIS SFCGAL
Component: sfcgal Version: master
Keywords: Cc:

Description

I think this is caused by a very recent change, because it wasn't crashing when I ran yesterday.

Now testing:

POSTGIS="2.2.0dev r13970" GEOS="3.5.0-CAPI-1.9.0 r4088" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.0, released 2015/06/14" LIBXML="2.7.8" LIBJSON="0.12" RASTER

I am getting a server crash o:

SELECT ST_3DDistance('POINT(-11.1111111 40)'::geometry, 'POLYGON((1 2,1 2,1 2,1 2))'::geometry);

Change History (10)

comment:1 by robe, 9 years ago

Component: postgissfcgal

I did a backtrace of this, and it seems my sfcgal is kicking. I don't know why it didn't yesterday though so could still be something to do with the r13970 change or my ineptness. Going to recheck.

Anyway the crash appears to be in SFCGAL from the backtrace:

#0  0x000000006d3048b0 in libSFCGAL!_ZN6SFCGAL7VersionEv () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#1  0x000000006d3048ee in libSFCGAL!_ZN6SFCGAL7VersionEv () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#2  0x000000006d3009b1 in libSFCGAL!_ZN6SFCGAL7VersionEv () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#3  0x000000006d51d59f in libSFCGAL!_ZN6SFCGAL10LineString8addPointERKNS_5PointE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#4  0x000000006d51c579 in libSFCGAL!_ZN6SFCGAL10LineString8addPointERKNS_5PointE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#5  0x000000006d517e8c in libSFCGAL!_ZN6SFCGAL10LineString8addPointERKNS_5PointE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#6  0x000000006d5377d9 in libSFCGAL!_ZN6SFCGAL10LineString8addPointERKNS_5PointE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#7  0x000000006d2f8c6b in libSFCGAL!_ZN6SFCGAL11triangulate20triangulatePolygon3DERKNS_7PolygonERNS_19TriangulatedSurfaceE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.d
#8  0x000000006d26c965 in libSFCGAL!_ZN6SFCGAL9algorithm22distancePointPolygon3DERKNS_5PointERKNS_7PolygonE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#9  0x000000006d26cb1b in libSFCGAL!_ZN6SFCGAL9algorithm23distancePointGeometry3DERKNS_5PointERKNS_8GeometryE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#10 0x000000006d26cbe4 in libSFCGAL!_ZN6SFCGAL9algorithm10distance3DERKNS_8GeometryES3_NS0_15NoValidityCheckE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#11 0x000000006d26cdd0 in libSFCGAL!_ZN6SFCGAL9algorithm10distance3DERKNS_8GeometryES3_ () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#12 0x000000006d2b8097 in sfcgal_geometry_distance_3d () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#13 0x0000000070891f7f in sfcgal_distance3D () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\lib\postgis-2.2.dll
#14 0x00000001401118e8 in postgres!ExecProject ()

comment:2 by robe, 9 years ago

Owner: changed from nicklas to colivier

comment:3 by robe, 9 years ago

Priority: blockerhigh

Okay user ineptness. I remarked out the CREATE EXTENSION sfcgal part but forgot to remark out the part about changing the backend to sfcgal in my scripts.

comment:4 by robe, 9 years ago

Summary: ST_3DDistance garden crash on malformed polygonsST_3DDistance sfcgal garden crash on malformed polygons

comment:5 by pramsey, 9 years ago

I get an exception but not a crash,

postgis22=# set postgis.backend = 'sfcgal';
SET
postgis22=# SELECT ST_3DDistance('POINT(-11.1111111 40)'::geometry, 'POLYGON((1 2,1 2,1 2,1 2))'::geometry);
ERROR:  floating-point exception
DETAIL:  An invalid floating-point operation was signaled. This probably means an out-of-range result or an invalid operation, such as division by zero.
postgis22=# set postgis.backend = 'geos';
SET
postgis22=# SELECT ST_3DDistance('POINT(-11.1111111 40)'::geometry, 'POLYGON((1 2,1 2,1 2,1 2))'::geometry);
NOTICE:  One or both of the geometries is missing z-value. The unknown z-value will be regarded as "any value"
  st_3ddistance   
------------------
 39.8833174657844
(1 row)

comment:6 by strk, 9 years ago

Same here (floating-point exception with sfcgal, notice with geos). SFGAL 2.1 from commit 24db3b8a2aec64db6da32b1cc6bf4d4a3840b9f8

comment:7 by robe, 9 years ago

You mean 1.2 right?

comment:8 by robe, 9 years ago

Which CGAL version are you guys using. I'm using CGAL 4.6.1 (though I recall I had the same issue with CGAL 4.2).

comment:9 by robe, 9 years ago

Oh by the way I had submitted this ticket to SFCGAL and it seems to be fixed now

https://github.com/Oslandia/SFCGAL/issues/108

I'll retest to confirm.

comment:10 by robe, 9 years ago

Milestone: PostGIS 2.2.0PostGIS SFCGAL
Resolution: fixed
Status: newclosed

confirmed it's fixed as of https://github.com/Oslandia/SFCGAL/commit/24db3b8a2aec64db6da32b1cc6bf4d4a3840b9f8

I now get

NOTICE:  During distance_3d(A,B) :
NOTICE:    with A: POINT(-6254999476204023/562949953421312 40/1)
NOTICE:     and B: POLYGON((1/1 2/1,1/1 2/1,1/1 2/1,1/1 2/1))


ERROR:  When converting to 3D - Polygon is invalid : ring 0 degenerated to a point : POLYGON((1/1 2/1 0/1,1/1 2/1 0/1,1/1 2/1 0/1,1/1 2/1 0/1))
********** Error **********

ERROR: When converting to 3D - Polygon is invalid : ring 0 degenerated to a point : POLYGON((1/1 2/1 0/1,1/1 2/1 0/1,1/1 2/1 0/1,1/1 2/1 0/1))
SQL state: XX000


Note: See TracTickets for help on using tickets.