#5586 closed defect (fixed)

Crash bug when using ST_Intersects

Reported by: Wenjing Owned by: pramsey
Priority: critical Milestone: PostGIS GEOS
Component: postgis Version: 3.4.x
Keywords: Cc:

Description (last modified by Wenjing)

DROP TABLE IF EXISTS t;
CREATE TABLE t (geom geometry);
INSERT INTO t (geom) VALUES ((ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,1 0))')));
INSERT INTO t (geom) SELECT ST_Boundary(t.geom) FROM t;
SELECT * FROM t As a1 JOIN t As a2 ON ST_Intersects(a1.geom, a2.geom);

stack trace:

Program received signal SIGSEGV, Segmentation fault.
0x00007fc000d0cf4c in ?? () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
(gdb) bt
#0  0x00007fc000d0cf4c in ?? () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
#1  0x00007fc000d34f22 in geos::algorithm::PointLocator::computeLocation(geos::geom::Coordinate const&, geos::geom::Geometry const*) () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
#2  0x00007fc000d35078 in geos::algorithm::PointLocator::computeLocation(geos::geom::Coordinate const&, geos::geom::Geometry const*) () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
#3  0x00007fc000d35209 in geos::algorithm::PointLocator::locate(geos::geom::Coordinate const&, geos::geom::Geometry const*) () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
#4  0x00007fc000d53aed in geos::geom::prep::BasicPreparedGeometry::isAnyTargetComponentInTest(geos::geom::Geometry const*) const () from /lib/x86_64-linux-gnu/libgeos.so.3.10.2
#5  0x00007fc00142c15c in GEOSPreparedIntersects_r () from /lib/x86_64-linux-gnu/libgeos_c.so.1
#6  0x00007fc001488f74 in ST_Intersects (fcinfo=0x55d8585cbaf0) at lwgeom_geos.c:2458
#7  0x000055d8577d57e2 in ExecInterpExpr (state=0x55d8585cb618, econtext=0x55d8585ca580, isnull=0x7ffd0c310a6f)
    at execExprInterp.c:758
#8  0x000055d85782ad25 in ExecEvalExprSwitchContext (state=0x55d8585cb618, econtext=0x55d8585ca580, 
    isNull=0x7ffd0c310a6f) at ../../../src/include/executor/executor.h:355
#9  0x000055d85782ae24 in ExecQual (state=0x55d8585cb618, econtext=0x55d8585ca580)
    at ../../../src/include/executor/executor.h:424
#10 0x000055d85782b15c in ExecNestLoop (pstate=0x55d8585ca478) at nodeNestloop.c:214
#11 0x000055d8577e13c3 in ExecProcNode (node=0x55d8585ca478) at ../../../src/include/executor/executor.h:273
#12 0x000055d8577e3cf0 in ExecutePlan (estate=0x55d8585ca248, planstate=0x55d8585ca478, use_parallel_mode=false, 
    operation=CMD_SELECT, sendTuples=true, numberTuples=0, direction=ForwardScanDirection, dest=0x55d85899c1f0, 
    execute_once=true) at execMain.c:1670
--Type <RET> for more, q to quit, c to continue without paging--
#13 0x000055d8577e1957 in standard_ExecutorRun (queryDesc=0x55d8589949c8, direction=ForwardScanDirection, count=0, 
    execute_once=true) at execMain.c:365
#14 0x000055d8577e17de in ExecutorRun (queryDesc=0x55d8589949c8, direction=ForwardScanDirection, count=0, 
    execute_once=true) at execMain.c:309
#15 0x000055d857a69ce0 in PortalRunSelect (portal=0x55d8585758c8, forward=true, count=0, dest=0x55d85899c1f0)
    at pquery.c:924
#16 0x000055d857a69942 in PortalRun (portal=0x55d8585758c8, count=9223372036854775807, isTopLevel=true, 
    run_once=true, dest=0x55d85899c1f0, altdest=0x55d85899c1f0, qc=0x7ffd0c310ea0) at pquery.c:768
#17 0x000055d857a62d1b in exec_simple_query (
    query_string=0x55d8584f5ea8 "SELECT * FROM t As a1 JOIN t As a2 ON ST_Intersects(a1.geom, a2.geom);")
    at postgres.c:1273
#18 0x000055d857a67a2b in PostgresMain (dbname=0x55d85852f868 "postgres", username=0x55d85852f850 "postgres")
    at postgres.c:4657
#19 0x000055d8579a003f in BackendRun (port=0x55d8585223a0) at postmaster.c:4423
#20 0x000055d85799f684 in BackendStartup (port=0x55d8585223a0) at postmaster.c:4108
#21 0x000055d85799c00d in ServerLoop () at postmaster.c:1767
#22 0x000055d85799b90f in PostmasterMain (argc=3, argv=0x55d8584ef7a0) at postmaster.c:1466
#23 0x000055d85786019b in main (argc=3, argv=0x55d8584ef7a0) at main.c:198

Change History (5)

comment:1 by Wenjing, 14 months ago

Description: modified (diff)

comment:2 by robe, 14 months ago

I can't replicate this issue on any of my PostGIS 3.4.0 or 3.5.0 dev setups even when running multiple times.

Can you provide us the output of:

SELECT postgis_full_version() || ' ' || version();

comment:3 by Wenjing, 14 months ago

It is from https://registry.hub.docker.com/r/postgis/postgis/.

POSTGIS="3.4.0 0874ea3" [EXTENSION] PGSQL="150" GEOS="3.9.0-CAPI-1.16.2" SFCGAL="1.3.8" PROJ="7.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=
https://cdn.proj.org USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.
10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY PostgreSQL 15.4 (Debian 15.4-1.pgdg110+1) on x86_64-pc-linux-
gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

comment:4 by Wenjing, 14 months ago

I think you have solved this issue. =-) Because it cannot be triggered in the newest version:

POSTGIS="3.5.0dev 3.4.0rc1-705-g5c3ec8392" [EXTENSION] PGSQL="170" GEOS="3.10.6dev-CAPI-1.16.3" PRO
J="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DAT
ABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13" PostgreSQL 17devel on x86_64-pc-linux-gnu, compi
led by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit

comment:5 by robe, 13 months ago

Milestone: PostGIS 3.4.1PostGIS GEOS
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.