Opened 4 years ago

Last modified 4 years ago

#4723 assigned defect

ST_ApproximateMedialAxis SFCGAL crash

Reported by: robe Owned by: robe
Priority: medium Milestone: PostGIS SFCGAL
Component: sfcgal Version: 2.5.x -- EOL
Keywords: Cc: pusik

Description (last modified by robe)

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 
SFCGAL function ApproximateMedialAxis couses fatal error on the server side. This happens on any installation of the PostGIS on different machines, so, memory error can be only from the function itself. Please, check. 2020-07-14 12:18:54.820 CEST [8812] LOG:  server process (PID 7824) was terminated by exception 0xC00000052020-07-14 12:18:54.820 CEST [8812] 
DETAIL:  Failed process was running: 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)))'))2020-07-14 12:18:54.820 CEST [8812] HINT:  See C include file "ntstatus.h" for a description of the hexadecimal value. 2020-07-14 11:57:48.210 CEST [8812] LOG:  server process (PID 7584) was terminated by exception 0xC00000052020-07-14 11:57:48.210 CEST [8812] DETAIL:  Failed process was running: 

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,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,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)),((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)))'))2020-07-14 11:57:48.210 CEST [8812] HINT:  See C include file "ntstatus.h" for a description of the hexadecimal value.  

This was reported by Nikolay Gerasimov

Change History (8)

comment:1 by robe, 4 years ago

Description: modified (diff)

comment:2 by robe, 4 years ago

Description: modified (diff)
Keywords: windows added

comment:3 by robe, 4 years ago

Looks like it hasn't been fixed yet. Algunenano tested building from sfcgal head (CGAL CGAL: 4.14.2) and he got the same crash.

His trace is here

Program terminated with signal SIGSEGV, Segmentation fault.
#0  CGAL::Straight_skeleton_builder_2<CGAL::Straight_skeleton_builder_traits_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epick>, CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> >, CGAL::Dummy_straight_skeleton_builder_2_visitor<CGAL::Straight_skeleton_2<CGAL::Epick, CGAL::Straight_skeleton_items_2, std::allocator<int> > > >::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_2<CGAL::Epeck>*, std::vector<CGAL::Point_2<CGAL::Epeck>, std::allocator<CGAL::Point_2<CGAL::Epeck> > > >, std::_List_const_iterator<CGAL::Polygon_2<CGAL::Epeck, std::vector<CGAL::Point_2<CGAL::Epeck>, std::allocator<CGAL::Point_2<CGAL::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=<optimized out>) at lwgeom_sfcgal.c:319
#11 0x00005563793c073d in ExecInterpExpr (state=<optimized out>, econtext=<optimized out>, isnull=0x7ffc871b43df) at execExprInterp.c:649
#12 0x000055637948a67e in ExecEvalExprSwitchContext (state=0x55637a556a90, econtext=0x55637a5458a0, isNull=0x7ffc871b43df) at ../../../../src/include/executor/executor.h:307
#13 evaluate_expr (expr=<optimized out>, 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=<optimized out>, context=0x7ffc871b4750, func_tuple=<optimized out>)
    at clauses.c:4354
#15 simplify_function (funcid=<optimized out>, result_type=11198173, result_typmod=-1, result_collid=0, input_collid=0, args_p=<optimized out>, funcvariadic=<optimized out>, process_args=<optimized out>, 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 0x0000556379420e39 in expression_tree_mutator (node=0x55637a51fa08, mutator=0x5563794889c0 <eval_const_expressions_mutator>, context=0x7ffc871b4750) at /usr/include/bits/string_fortified.h:34
#18 0x0000556379488acb in eval_const_expressions_mutator (node=0x55637a51fa08, context=0x7ffc871b4750) at clauses.c:3539
#19 0x0000556379421116 in expression_tree_mutator (node=<optimized out>, 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=<optimized out>, node=0x55637a50c9f0) at clauses.c:2269
#22 0x0000556379471e3b in preprocess_expression (root=0x55637a51fb08, expr=0x55637a5458a0, kind=1) at planner.c:1087
#23 subquery_planner (glob=<optimized out>, parse=0x55637a464d18, parent_root=<optimized out>, hasRecursion=<optimized out>, 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=<optimized out>, 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=<optimized out>, argv=<optimized out>, dbname=<optimized out>, username=<optimized out>) 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 ServerLoop () at postmaster.c:1704
#32 0x00005563794b5cb6 in PostmasterMain (argc=3, argv=0x55637a45d2a0) at postmaster.c:1377
#33 0x000055637941eea5 in main (argc=3, argv=0x55637a45d2a0) at main.c:228
(gdb) 

comment:4 by robe, 4 years ago

Keywords: windows removed
Summary: ST_ApproximateMedialAxis SFCGAL crash on windowsST_ApproximateMedialAxis SFCGAL crash

comment:5 by robe, 4 years ago

Posted to SFCGAL related ticket is - https://gitlab.com/Oslandia/SFCGAL/-/issues/232

comment:6 by robe, 4 years ago

updated note from SFCGAL. May not be an issue with CGAL 5.x so I'll try to compile with that and see if it fixes it in windows.

comment:7 by robe, 4 years ago

Cc: pusik added

Sadly rebuilding against CGAL 5.0.2 and SFCGAL 1.3.8 still makes that example crash.

POSTGIS="3.1.0dev 3.1.0alpha1-164-g3bd678013" [EXTENSION] PGSQL="130" GEOS="3.9.0-CAPI-1.14.0" SFCGAL="1.3.8" PROJ="6.2.1" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" PostgreSQL 13beta2 on x86_64-w64-mingw32, compiled by gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0, 64-bit

as noted in the SFCGAL related ticket

@lbartoletti

was able to get it to work on FreeBSD with CGAL 5.0.2

comment:8 by robe, 4 years ago

Milestone: PostGIS 3.0.2PostGIS SFCGAL
Note: See TracTickets for help on using tickets.