ST_ApproximateMedialAxis crashes on PostGIS
SELECT st_approximatemedialaxis(st_geomfromtext('MULTIPOLYGON(((62725 53915,62725 55415,62725 55975,62665 55975,62665 56075,62725 56075,62725 58675,61475 58675,61475 56075,61865 56075,61865 55975,60025 55975,58775 55975,55915 55975,55115 55975,54725 55975,54725 56075,55115 56075,55915 56075,55975 56075,55975 58675,56075 58675,56075 57425,57425 57425,57425 56075,58775 56075,60025 56075,61375 56075,61375 61375,60125 61375,60125 61475,65525 61475,65525 61135,65425 61135,65425 61375,61475 61375,61475 58775,65425 58775,65425 60185,65525 60185,65525 58675,62825 58675,62825 55415,62825 53915,62825 53855,62725 53855,62725 53915)),((64075 65425,60125 65425,60125 65525,65425 65525,65425 66875,65425 68125,65425 69475,60125 69475,60125 69575,64075 69575,64075 72175,64175 72175,64175 69575,65525 69575,65525 68125,65525 66875,65525 62725,65425 62725,65425 64075,64075 64075,64075 65425)))'))
Crashes on PostGIS 3.0.1
POSTGIS="3.0.1 3.0.1" [EXTENSION] PGSQL="120" GEOS="3.8.0-CAPI-1.13.1 " SFCGAL="1.3.2" PROJ="Rel. 5.2.0, September 15th, 2018" GDAL="GDAL 2.4.4, released 2020/01/08" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.4.3 (Internal)" TOPOLOGY RASTER
and also on Linux with SFCGAL head and CGAL: 4.14.2
trace of Linux crash:
Program terminated with signal SIGSEGV, Segmentation fault. #0 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::GetTrisegment (aV=..., this=0x7ffc871b3dc0) at /usr/include/boost/smart_ptr/intrusive_ptr.hpp:191 191 T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT (gdb) bt #0 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::GetTrisegment (aV=..., this=0x7ffc871b3dc0) at /usr/include/boost/smart_ptr/intrusive_ptr.hpp:191 #1 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::AreSkeletonNodesCoincident (aY=..., aX=..., this=0x7ffc871b3dc0) at /usr/include/CGAL/Straight_skeleton_builder_2.h:554 #2 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::MergeCoincidentNodes (this=this@entry=0x7ffc871b3dc0) at /usr/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h:1713 #3 0x00007f87b4a61511 in CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::FinishUp (this=0x7ffc871b3dc0) at /usr/include/c++/10.1.0/bits/stl_algo.h:3838 #4 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::Run (this=0x7ffc871b3dc0) at /usr/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h:1787 #5 CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2CGAL::Epick, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator > > >::construct_skeleton (this=this@entry=0x7ffc871b3dc0, aNull_if_failed=aNull_if_failed@entry=true) at /usr/include/CGAL/Straight_skeleton_2/Straight_skeleton_builder_2_impl.h:1797 #6 0x00007f87b4a35085 in CGAL::create_interior_straight_skeleton_2<__gnu_cxx::__normal_iterator<CGAL::Point_2CGAL::Epeck*, std::vector<CGAL::Point_2CGAL::Epeck, std::allocator<CGAL::Point_2CGAL::Epeck > > >, std::_List_const_iterator<CGAL::Polygon_2<CGAL::Epeck, std::vector<CGAL::Point_2CGAL::Epeck, std::allocator<CGAL::Point_2CGAL::Epeck > > > >, CGAL::Epick> (aHolesEnd=..., aHolesBegin=..., aOuterContour_VerticesEnd=..., aOuterContour_VerticesBegin=...) at /usr/include/CGAL/create_straight_skeleton_2.h:84 #7 SFCGAL::algorithm::(anonymous namespace)::straightSkeleton (poly=...) at /home/raul/.cache/yay/sfcgal-git/src/sfcgal/src/algorithm/straightSkeleton.cpp:191 #8 0x00007f87b4a3662b in SFCGAL::algorithm::approximateMedialAxis (g=...) at /home/raul/.cache/yay/sfcgal-git/src/sfcgal/src/algorithm/straightSkeleton.cpp:359 #9 0x00007f87b4ac10cc in sfcgal_geometry_approximate_medial_axis (ga=0x55637a58ed30) at /home/raul/.cache/yay/sfcgal-git/src/sfcgal/src/capi/sfcgal_c.cpp:782 #10 0x00007f87b50331f9 in sfcgal_approximate_medial_axis (fcinfo=) at lwgeom_sfcgal.c:319 #11 0x00005563793c073d in ExecInterpExpr (state=, econtext=, isnull=0x7ffc871b43df) at execExprInterp.c:649 #12 0x000055637948a67e in ExecEvalExprSwitchContext (state=0x55637a556a90, econtext=0x55637a5458a0, isNull=0x7ffc871b43df) at ../../../../src/include/executor/executor.h:307 #13 (closed) evaluate_expr (expr=, result_type=11198173, result_typmod=-1, result_collation=0) at clauses.c:4812 #14 0x000055637948b0fd in evaluate_function (funcid=12296625, result_type=11198173, result_typmod=-1, result_collid=0, input_collid=0, args=0x55637a5209c8, funcvariadic=, context=0x7ffc871b4750, func_tuple=) at clauses.c:4354 #15 simplify_function (funcid=, result_type=11198173, result_typmod=-1, result_collid=0, input_collid=0, args_p=, funcvariadic=, process_args=, allow_non_const=true, context=0x7ffc871b4750) at clauses.c:3984 #16 0x0000556379489523 in eval_const_expressions_mutator (node=0x55637a51f988, context=0x7ffc871b4750) at clauses.c:2477 #17 (closed) 0x0000556379420e39 in expression_tree_mutator (node=0x55637a51fa08, mutator=0x5563794889c0 <eval_const_expressions_mutator>, context=0x7ffc871b4750) at /usr/include/bits/string_fortified.h:34 #18 (closed) 0x0000556379488acb in eval_const_expressions_mutator (node=0x55637a51fa08, context=0x7ffc871b4750) at clauses.c:3539 #19 0x0000556379421116 in expression_tree_mutator (node=, mutator=0x5563794889c0 <eval_const_expressions_mutator>, context=0x7ffc871b4750) at nodeFuncs.c:3012 #20 0x0000556379488acb in eval_const_expressions_mutator (node=0x55637a51f9d8, context=0x7ffc871b4750) at clauses.c:3539 #21 0x00005563794889a0 in eval_const_expressions (root=, node=0x55637a50c9f0) at clauses.c:2269 #22 (closed) 0x0000556379471e3b in preprocess_expression (root=0x55637a51fb08, expr=0x55637a5458a0, kind=1) at planner.c:1087 #23 subquery_planner (glob=, parse=0x55637a464d18, parent_root=, hasRecursion=, tuple_fraction=0) at planner.c:769 #24 0x000055637947143f in standard_planner (parse=0x55637a464d18, cursorOptions=256, boundParams=0x0) at planner.c:406 #25 0x0000556379544e91 in pg_plan_query (querytree=0x55637a464d18, cursorOptions=256, boundParams=0x0) at postgres.c:878 #26 pg_plan_queries (querytrees=, cursorOptions=256, boundParams=0x0) at postgres.c:968 #27 0x00005563795491a4 in exec_simple_query ( query_string=0x55637a463580 "select st_approximatemedialaxis(st_geomfromtext('MULTIPOLYGON(((55115 56075,55915 56075,55975 56075,55975 58675,56075 58675,56075 57425,57425 57425,57425 56075,58775 56075,60025 56075,61375 56075,6137"...) at postgres.c:1143 #28 0x0000556379546ccb in PostgresMain (argc=, argv=, dbname=, username=) at postgres.c:4243 #29 0x00005563794b9686 in BackendRun (port=0x55637a489560) at postmaster.c:4448 #30 0x00005563794b8cf4 in BackendStartup (port=0x55637a489560) at postmaster.c:4139 #31 (closed) ServerLoop () at postmaster.c:1704 #32 (closed) 0x00005563794b5cb6 in PostmasterMain (argc=3, argv=0x55637a45d2a0) at postmaster.c:1377 #33 (closed) 0x000055637941eea5 in main (argc=3, argv=0x55637a45d2a0) at main.c:228
This is already ticketed on PostGIS - at https://trac.osgeo.org/postgis/ticket/4723