yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.93k stars 1.06k forks source link

[YSQL][PostGIS] Segmentation fault in ST_MaximumInscribedCircle() #11321

Open def- opened 2 years ago

def- commented 2 years ago

Jira Link: DB-1149

Description

See https://docs.yugabyte.com/latest/api/ysql/extensions/#postgis for PostGIS installation instructions.

Can be reproduced against yugabyte-2.11.2.0 on CentOS using https://github.com/def-/postgis/tree/stable-3.1/regress by running PATH=$CWD/bin/:$PATH ./run_test.pl core/dumppoints.sql

tserver log:

2022-02-01 09:13:45.151 UTC [4020] LOG:  server process (PID 3489) was terminated by signal 11: Segmentation fault
2022-02-01 09:13:45.151 UTC [4020] DETAIL:  Failed process was running: SELECT 'mic-box' AS name,
               st_astext(center, 4) AS center,
               st_astext(nearest, 4) AS nearest,
               round(radius::numeric,4) AS radius
        FROM ST_MaximumInscribedCircle('Polygon((0 0, 100 0, 99 98, 0 100, 0 0))'::geometry);

backtrace from gdb:

Program terminated with signal 11, Segmentation fault.
#0  HeapTupleHeaderGetDatum (tuple=0x0) at ../../../../../../src/postgres/src/backend/executor/execTuples.c:1385
1385    ../../../../../../src/postgres/src/backend/executor/execTuples.c: No such file or directory.
(gdb) bt
#0  HeapTupleHeaderGetDatum (tuple=0x0) at ../../../../../../src/postgres/src/backend/executor/execTuples.c:1385
#1  0x00007fa9576b6a47 in ST_MaximumInscribedCircle () from /nfusr/dev-server/dfelsing/yugabyte-2.11.2.0/postgres/lib/postgis-3.so
#2  0x00000000006da32c in ExecMakeTableFunctionResult (setexpr=0x38fe568, econtext=0x38fe438, argContext=<optimized out>, expectedDesc=0x38ff730, randomAccess=false)
    at ../../../../../../src/postgres/src/backend/executor/execSRF.c:231
#3  0x00000000006e9a60 in FunctionNext (node=node@entry=0x38fe328) at ../../../../../../src/postgres/src/backend/executor/nodeFunctionscan.c:94
#4  0x00000000006d94aa in ExecScanFetch (recheckMtd=0x6e9770 <FunctionRecheck>, accessMtd=0x6e97a0 <FunctionNext>, node=0x38fe328) at ../../../../../../src/postgres/src/backend/executor/execScan.c:95
#5  ExecScan (node=0x38fe328, accessMtd=0x6e97a0 <FunctionNext>, recheckMtd=0x6e9770 <FunctionRecheck>) at ../../../../../../src/postgres/src/backend/executor/execScan.c:171
#6  0x00000000006ce5db in ExecProcNode (node=0x38fe328) at ../../../../../../src/postgres/src/include/executor/executor.h:249
#7  ExecutePlan (execute_once=<optimized out>, dest=0x38eb870, direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>, operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x38fe328,
    estate=0x38fe118) at ../../../../../../src/postgres/src/backend/executor/execMain.c:1730
#8  standard_ExecutorRun (queryDesc=0x335f118, direction=<optimized out>, count=0, execute_once=<optimized out>) at ../../../../../../src/postgres/src/backend/executor/execMain.c:367
#9  0x00007fa96624d8bd in pgss_ExecutorRun (queryDesc=0x335f118, direction=ForwardScanDirection, count=0, execute_once=<optimized out>)
    at ../../../../../src/postgres/contrib/pg_stat_statements/pg_stat_statements.c:947
#10 0x00007fa9660463aa in ybpgm_ExecutorRun (queryDesc=0x335f118, direction=ForwardScanDirection, count=0, execute_once=<optimized out>) at ../../../../../src/postgres/contrib/yb_pg_metrics/yb_pg_metrics.c:499
#11 0x000000000088564b in PortalRunSelect (portal=portal@entry=0x365e118, forward=forward@entry=true, count=0, count@entry=9223372036854775807, dest=dest@entry=0x38eb870)
    at ../../../../../../src/postgres/src/backend/tcop/pquery.c:955
#12 0x0000000000887141 in PortalRun (portal=portal@entry=0x365e118, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x38eb870,
    altdest=altdest@entry=0x38eb870, completionTag=0x7ffc0fa760e0 "") at ../../../../../../src/postgres/src/backend/tcop/pquery.c:784
#13 0x0000000000884ad8 in exec_simple_query (
    query_string=0x358a118 "SELECT 'mic-box' AS name,\n       st_astext(center, 4) AS center,\n       st_astext(nearest, 4) AS nearest,\n       round(radius::numeric,4) AS radius\nFROM ST_MaximumInscribedCircle('Polygon((0 0, 100 0,"..., query_string@entry=0x7ffc0fa76060 "\030\341e\003") at ../../../../../../src/postgres/src/backend/tcop/postgres.c:1161
#14 yb_exec_simple_query_impl (query_string=query_string@entry=0x358a118) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:4434
#15 0x000000000087f8b8 in yb_exec_query_wrapper (exec_context=exec_context@entry=0x358a000, restart_data=restart_data@entry=0x7ffc0fa762b0, functor=functor@entry=0x884620 <yb_exec_simple_query_impl>,
    functor_context=functor_context@entry=0x358a118) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:4419
#16 0x00000000008802ec in yb_exec_simple_query (
    query_string=query_string@entry=0x358a118 "SELECT 'mic-box' AS name,\n       st_astext(center, 4) AS center,\n       st_astext(nearest, 4) AS nearest,\n       round(radius::numeric,4) AS radius\nFROM ST_MaximumInscribedCircle('Polygon((0 0, 100 0,"..., exec_context=exec_context@entry=0x358a000) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:4449
#17 0x0000000000882213 in PostgresMain (argc=<optimized out>, argv=argv@entry=0x35cb758, dbname=0x35cb638 "postgis_reg", username=0x3585fe8 "yugabyte")
    at ../../../../../../src/postgres/src/backend/tcop/postgres.c:5084
#18 0x000000000049e292 in BackendRun (port=0x3474960) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:4470
#19 BackendStartup (port=0x3474960) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:4136
#20 ServerLoop () at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1754
#21 0x00000000007ea21f in PostmasterMain (argc=argc@entry=23, argv=argv@entry=0x334e000) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1417
#22 0x000000000073588a in PostgresServerProcessMain (argc=23, argv=0x334e000) at ../../../../../../src/postgres/src/backend/main/main.c:234
#23 0x0000000000735a89 in main ()

Coredump: core.3489.zip

andrei-mart commented 2 years ago

Can not reproduce

yugabyte=# SELECT 'mic-box' AS name,
yugabyte-#                st_astext(center, 4) AS center,
yugabyte-#                st_astext(nearest, 4) AS nearest,
yugabyte-#                round(radius::numeric,4) AS radius
yugabyte-#         FROM ST_MaximumInscribedCircle('Polygon((0 0, 100 0, 99 98, 0 100, 0 0))'::geometry);
ERROR:  The GEOS version this PostGIS binary was compiled against (30702) doesn't support 'GEOSMaximumInscribedCircle' function (3.9.0+ required)

Though query fails, the failure reason is valid and correct. Also see https://github.com/yugabyte/yugabyte-db/issues/11318#issuecomment-1040875605

def- commented 2 years ago

See my comment for full setup instructions to get postgis working: https://github.com/yugabyte/yugabyte-db/issues/11318#issuecomment-1042798619 Can still reproduce with:

$ PATH=$PWD/bin:/usr/pgsql-11/bin:$PATH POSTGIS_SCRIPTDIR=/usr/pgsql-11/share/contrib/postgis-3.1 ./run_test.pl core/dumppoints.sql