[postgis-tickets] [PostGIS] #5145: segfault with select ST_Node(ST_GeomFromText('LINESTRING EMPTY'))

PostGIS trac at osgeo.org
Wed May 4 06:20:35 PDT 2022


#5145: segfault with select ST_Node(ST_GeomFromText('LINESTRING EMPTY'))
------------------------+--------------------------
 Reporter:  cactusbone  |      Owner:  pramsey
     Type:  defect      |     Status:  new
 Priority:  medium      |  Milestone:  PostGIS GEOS
Component:  postgis     |    Version:  3.2.x
 Keywords:              |
------------------------+--------------------------
 Using PostGIS docker image 14-3.2-alpine, which ships with postgis 3.2.1
 and geos 3.10,

 I have a segfault with `select ST_Node(ST_GeomFromText('LINESTRING
 EMPTY'))`

 here's the core dump backtrace


 {{{
 #0  0x00007f36bc780cc7 in
 geos::noding::SegmentNodeList::add(geos::geom::Coordinate const&, unsigned
 long) () from /usr/lib/libgeos.so.3.10.2
 #1  0x00007f36bc780dea in geos::noding::SegmentNodeList::addEndpoints() ()
 from /usr/lib/libgeos.so.3.10.2
 #2  0x00007f36bc781539 in
 geos::noding::SegmentNodeList::addSplitEdges(std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> >&) () from
 /usr/lib/libgeos.so.3.10.2
 #3  0x00007f36bc77c5c4 in
 geos::noding::NodedSegmentString::getNodedSubstrings(std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> > const&,
 std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> >*) () from
 /usr/lib/libgeos.so.3.10.2
 #4  0x00007f36bc77c661 in
 geos::noding::NodedSegmentString::getNodedSubstrings(std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> > const&) () from
 /usr/lib/libgeos.so.3.10.2
 #5  0x00007f36bc778f1c in
 geos::noding::IteratedNoder::node(std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> >*, int&,
 geos::geom::Coordinate&) () from /usr/lib/libgeos.so.3.10.2
 #6  0x00007f36bc77900c in
 geos::noding::IteratedNoder::computeNodes(std::vector<geos::noding::SegmentString*,
 std::allocator<geos::noding::SegmentString*> >*) () from
 /usr/lib/libgeos.so.3.10.2
 #7  0x00007f36bc777f27 in geos::noding::GeometryNoder::getNoded() () from
 /usr/lib/libgeos.so.3.10.2
 #8  0x00007f36bc778030 in
 geos::noding::GeometryNoder::node(geos::geom::Geometry const&) () from
 /usr/lib/libgeos.so.3.10.2
 #9  0x00007f36bcd811d7 in GEOSNode_r () from /usr/lib/libgeos_c.so.1
 #10 0x00007f36bcc632d0 in lwgeom_node
 (lwgeom_in=lwgeom_in at entry=0x7f36bcdfbbd8) at lwgeom_geos_node.c:156
 #11 0x00007f36bcb6e9bc in ST_Node (fcinfo=0x7f36bcdb8d38) at
 lwgeom_geos.c:3331
 #12 0x000056163af61227 in ExecInterpExpr ()
 #13 0x000056163b024c30 in evaluate_expr ()
 #14 0x000056163b024e81 in simplify_function ()
 #15 0x000056163b025d40 in eval_const_expressions_mutator ()
 #16 0x000056163afcc229 in expression_tree_mutator ()
 #17 0x000056163afcc4ae in expression_tree_mutator ()
 #18 0x000056163b026d5f in eval_const_expressions ()
 #19 0x000056163b00e0b8 in preprocess_expression ()
 #20 0x000056163b0149a3 in subquery_planner ()
 #21 0x000056163b015383 in standard_planner ()
 #22 0x000056163b0cfceb in pg_plan_query ()
 #23 0x000056163b0cfdd1 in pg_plan_queries ()
 #24 0x000056163b0d00a5 in exec_simple_query ()
 #25 0x000056163b0d2035 in PostgresMain ()
 #26 0x000056163b053f73 in ServerLoop ()
 #27 0x000056163b054de1 in PostmasterMain ()
 #28 0x000056163addcbce in main ()
 }}}

 I'm not sure if the bug is in geos OR PostGIS, so I'm opening it in both
 places :)
 See https://github.com/libgeos/geos/issues/601

 to reproduce easily:
 - start docker container `docker run --rm --name some-postgres -e
 POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis:14-3.2-alpine`
 (remove `-d` to not start in background)
 - run query using another container `docker run -it --rm --link some-
 postgres postgres psql postgresql://postgres:mysecretpassword@some-
 postgres -c "select ST_Node(ST_GeomFromText('LINESTRING EMPTY'))"`

 > 2022-05-04 12:16:36.761 UTC [1] LOG:  server process (PID 63) was
 terminated by signal 11: Segmentation fault
 >
 > 2022-05-04 12:16:36.761 UTC [1] DETAIL:  Failed process was running:
 select ST_Node(ST_GeomFromText('LINESTRING EMPTY'))

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5145>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list