Opened 9 years ago

Closed 9 years ago

#3153 closed defect (fixed)

garden Crash in ST_3DArea in sfcgal

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

Description (last modified by robe)

I'm guessing this function doesn't use proj or gdal in any way, so the crash should have nothing to do with the fact I'm running GDAL 2.0.0 and proj 4.9.1. I notice it's crashing in sfcgal, so probably has to do with fact I was doing postgis garden including CREATE EXTENSION postgis_sfcgal;

-- crashes
SELECT ST_3DArea(ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((0 0 2,10 0 1,10 10 -2,0 10 -5,0 0 -5),(5 5 6,7 5 6,7 7 6,5 7 10,5 5 -2)))') );

-- works fine
SELECT ST_3Area(ST_GeomFromEWKT('SRID=4326;MULTIPOLYGONM(((0 0 2,10 0 1,10 10 -2,0 10 -5,0 0 -5),(5 5 6,7 5 6,7 7 6,5 7 10,5 5 -2)))') );

SELECT postgis_full_version() || ' ' || version();

POSTGIS="2.2.0dev r13629" GEOS="3.5.0dev-CAPI-1.9.0 r4057" SFCGAL="1.0.5" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.0, released 2015/06/05" LIBXML="2.7.8" LIBJSON="0.12" RASTER PostgreSQL 9.4.1, compiled by Visual C++ build 1800, 64-bit

— backtrace looks like:

#0  0x000007fefd30aaad in RaiseException () from C:\Windows\system32\KernelBase.dll
#1  0x000000006144cce6 in libgcc_s_seh-1!_Unwind_RaiseException () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libgcc_s_seh-1.dll
#2  0x000000006fcb5dc2 in libstdc++-6!.cxa_throw () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libstdc++-6.dll
#3  0x000000006d47013a in libSFCGAL!_ZN5boost13serialization9singletonISt8multisetIPKNS0_18extended_type_infoENS0_6detail11key_compareESaIS5_EEE20get_mutable_instanceEv () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#4  0x000000006d4728b0 in libSFCGAL!_ZN5boost13serialization9singletonISt8multisetIPKNS0_18extended_type_infoENS0_6detail11key_compareESaIS5_EEE20get_mutable_instanceEv () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#5  0x000000006d244832 in libSFCGAL!_ZN6SFCGAL9algorithm6area3DERKNS_8GeometryE () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#6  0x000000006d297a6f in sfcgal_geometry_area_3d () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\bin\libSFCGAL.dll
#7  0x00000000708916f9 in sfcgal_area3D () from C:\ming64gcc48\projects\postgresql\rel\pg9.4w64gcc48edb\lib\postgis-2.2.dll
#8  0x00000001401118e8 in postgres!ExecProject ()

What I find especially troubling about this is that even when I do:

set postgis.backend = geos;

It still goes thru SFCGAL. It's my understanding that functions written in both, the geos/liblwgeom one should be used if geos is backend.

I should add, its not specific to the M I used. If I switch the M's to Z's it crashes there too.

Change History (2)

comment:1 by robe, 9 years ago

Description: modified (diff)

comment:2 by robe, 9 years ago

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

I retested this with SFCGAL 1.2.0 (not yet released ) and doesn't crash anymore just errors — so gives this:

NOTICE:  During area_3d(A) :
NOTICE:    with A: MULTIPOLYGON(((0/1 0/1,10/1 0/1,10/1 10/1,0/1 10/1,0/1 0/1),(5/1 5/1,7/1 5/1,7/1 7/1,5/1 7/1,5/1 5/1)))


ERROR:  When converting to 3D - MultiPolygon is invalid : Polygon 0 is invalid: interior ring 0 is oriented in the same direction as exterior ring : MULTIPOLYGON(((0/1 0/1 0/1,10/1 0/1 0/1,10/1 10/1 0/1,0/1 10/1 0/1,0/1 0/1 0/1),(5/1 5/1 0/1,7/1 5/1 0/1,7/1 7/1 0
********** Error **********

ERROR: When converting to 3D - MultiPolygon is invalid : Polygon 0 is invalid: interior ring 0 is oriented in the same direction as exterior ring : MULTIPOLYGON(((0/1 0/1 0/1,10/1 0/1 0/1,10/1 10/1 0/1,0/1 10/1 0/1,0/1 0/1 0/1),(5/1 5/1 0/1,7/1 5/1 0/1,7/1 7/1 0
SQL state: XX000
Note: See TracTickets for help on using tickets.