[postgis-users] PostGIS crash on ST_ConcaveHull

36 views
Skip to first unread message

耳辰

unread,
Aug 18, 2023, 9:03:51 AM8/18/23
to postgis-users, 宋震(凡玺), 谢炯

Hi guys,

I met a postgis crash when tried to use ST_ConvaveHull function with a multipoint, in postgis 3.3.2 and Geos 3.11.2 :

select ST_ConcaveHull('MULTIPOINT ((113.56577197798602 22.80081530883069),(113.565723279387 22.800815316487014),(113.56571548761124 22.80081531771092),(113.56571548780202 22.800815317674463),(113.56577197817877 22.8008153088047),(113.56577197798602 22.80081530883069))', 0.75);

The crash stack are listed:
#0  0x0000ffff84e02210 in geos::triangulate::tri::Tri::getIndex(geos::triangulate::tri::Tri const*) const () from /home/erchen.cz/pgsql15/lib/libgeos.so.3.11.2
#1  0x0000ffff84ce74c0 in geos::algorithm::hull::HullTriangulation::nextBorderTri(geos::algorithm::hull::HullTri*) ()
#2  0x0000ffff84ce7698 in geos::algorithm::hull::HullTriangulation::traceBoundary(geos::triangulate::tri::TriList<geos::algorithm::hull::HullTri>&) ()
#3  0x0000ffff84ce79d4 in geos::algorithm::hull::HullTriangulation::traceBoundaryPolygon(geos::triangulate::tri::TriList<geos::algorithm::hull::HullTri>&, geos::geom::GeometryFactory const*) ()
#4  0x0000ffff84ce1f28 in geos::algorithm::hull::ConcaveHull::toGeometry(geos::triangulate::tri::TriList<geos::algorithm::hull::HullTri>&, geos::geom::GeometryFactory const*) () from /home/erchen.cz/pgsql15/lib/libgeos.so.3.11.2
#5  0x0000ffff84ce29d4 in geos::algorithm::hull::ConcaveHull::getHull() ()
#6  0x0000ffff8e54818c in GEOSConcaveHull_r ()
….

It seemed that geos was failed to triangulate the multipoint and then crashed … Is this a bug of geos?

Any comment is welcomed.
Regards,

Zhen

Imre Samu

unread,
Aug 18, 2023, 10:39:45 AM8/18/23
to 耳辰, PostGIS Users Discussion, 宋震(凡玺), 谢炯
Any comment is welcomed.

Hi Zhen,

I've recently tested your example with the "postgis/postgis:15-master" Docker image
[GEOS version: 3.13.0dev-CAPI-1.18.0 + PostGIS version: 3.5.0dev 3.4.0rc1-21-g7faeed1d4], 
and it appears that it crashes as well [1].

However, I found that the CGAL-based alternative ST_AlphaShape is working without issues.   [1]+[2] 

postgres=# select ST_AlphaShape('MULTIPOINT ((113.56577197798602 22.80081530883069),(113.565723279387 22.800815316487014),(113.56571548761124 22.80081531771092),(113.56571548780202 22.800815317674463),(113.56577197817877 22.8008153088047),(113.56577197798602 22.80081530883069))'::geometry, 0.75 );

                     st_alphashape                                                          
---------------------------------------------------
 010300000001000000070000006288BBAE34645C404AB48F3B02CD364065E369CF34645C4097728A3B02CD36405D9CAB9B35645C405F90693B02CD364059D1AB9B35645C40CC73693B02CD364065E369CF34645C4097728A3B02CD3640D3B
CBBAE34645C40348C8F3B02CD36406288BBAE34645C404AB48F3B02CD3640
(1 row)


[1]
tested with "postgis/postgis:15-master"  https://github.com/postgis/docker-postgis
  POSTGIS="3.5.0dev 3.4.0rc1-21-g7faeed1d4" [EXTENSION] PGSQL="150"
  GEOS="3.13.0dev-CAPI-1.18.0" SFCGAL="SFCGAL 1.5.0, CGAL 5.6.1, BOOST 1.74.0" PROJ="9.3.0 NETWORK_ENABLED=OFF
  URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj 
  DATABASE_PATH=/usr/local/share/proj/proj.db" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0
  (Internal)" TOPOLOGY


This function effectively computes a concave hull of a geometry in a similar way to ST_ConcaveHull, but uses CGAL and a different algorithm.
Availability: 3.3.0 - requires SFCGAL >= 1.4.1.   ;  This method needs SFCGAL backend.

Regards,
  Imre



_______________________________________________
postgis-users mailing list
postgi...@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Paul Ramsey

unread,
Aug 18, 2023, 11:12:31 AM8/18/23
to 耳辰, PostGIS Users Discussion, "宋震(凡玺)", 谢炯
Thanks, yes a crash is a bug. I have confirmed it exists in GEOS, and filed an issue


P

耳辰

unread,
Aug 18, 2023, 8:44:59 PM8/18/23
to Paul Ramsey, PostGIS Users Discussion, 宋震(凡玺), 谢炯

Many thanks,

zhen





陈振
阿里巴巴
电话:057128223456-83773183
地址:北京-北京-金辉大厦 33F-086
阿里巴巴 企业主页
信息安全声明:本邮件包含信息归发件人所在组织所有,发件人所在组织对该邮件拥有所有权利。
请接收者注意保密,未经发件人书面许可,不得向任何第三方组织和个人透露本邮件所含信息的全部或部分。以上声明仅适用于工作邮件。
Information Security Notice: The information contained in this mail is solely property of the sender's organization.
This mail communication is confidential. Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.
------------------------------------------------------------------
发件人:Paul Ramsey<pra...@cleverelephant.ca>
日 期:2023年08月18日 23:12:14
收件人:耳辰<erch...@alibaba-inc.com>; PostGIS Users Discussion<postgi...@lists.osgeo.org>
抄 送:宋震(凡玺)<songz...@alibaba-inc.com>; 谢炯<xieji...@alibaba-inc.com>
主 题:Re: [postgis-users] PostGIS crash on ST_ConcaveHull

耳辰

unread,
Aug 18, 2023, 8:51:47 PM8/18/23
to Imre Samu, PostGIS Users Discussion, 宋震(凡玺), 谢炯

Hi  Imre,

Thanks very much and I will try ST_AlphaShape later.

As an alternative way, I back port the ST_ConcaveHull implementation based on pgplsql which used for lower GEOS version. It’s working and may loss performance. 

Looking forward to the bug fix of the issue.

Regards,

Zhen


------------------------------------------------------------------
发件人:Imre Samu <pella...@gmail.com>
发送时间:2023年8月18日(星期五) 22:39
收件人:陈振(耳辰) <erch...@alibaba-inc.com>; PostGIS Users Discussion <postgi...@lists.osgeo.org>
抄 送:宋震(凡玺) <songz...@alibaba-inc.com>; 谢炯 <xieji...@alibaba-inc.com>
主 题:Re: [postgis-users] PostGIS crash on ST_ConcaveHull

Reply all
Reply to author
Forward
0 new messages