Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault with select ST_Node(ST_GeomFromText('LINESTRING EMPTY')) #601

Closed
Cactusbone opened this issue May 4, 2022 · 3 comments
Closed

Comments

@Cactusbone
Copy link

Cactusbone commented May 4, 2022

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@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://trac.osgeo.org/postgis/ticket/5145

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'))

@Cactusbone
Copy link
Author

Cactusbone commented May 4, 2022

I think before the fix to #539 it was triggering an assert (in geos 3.9)

Using geos 3.9:
docker run --rm --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis:14-3.2 (version shipped with debian bullseye includes geos 3.9)

postgres: postgres postgres 172.17.0.3(50986) SELECT: MonotoneChainBuilder.cpp:76: static std::size_t geos::index::chain::MonotoneChainBuilder::findChainEnd(const geos::geom::CoordinateSequence&, std::size_t): Assertion `start < npts' failed.

I also get the same assert using postgis/postgis:12-2.5 which ships with geos 3.7.1 (from select postgis_full_version())

@pramsey
Copy link
Member

pramsey commented May 4, 2022

This enjoyably crashes for me too, I think I'm on the head of geos. Anyways, nice clear reproducer.

@pramsey
Copy link
Member

pramsey commented May 4, 2022

Fixed at 49c84d5.

pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit to pramsey/geos that referenced this issue May 4, 2022
pramsey added a commit that referenced this issue May 4, 2022
@pramsey pramsey closed this as completed May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants