okbob/plpgsql_check

Server crashes when trying to execute select f1()

nkPit opened this issue · 3 comments

Hello!

After building postgres in the following way:

./configure --enable-tap-tests --enable-debug --enable-cassert && make -j8

And executing the query:

set plpgsql_check.profiler to on;

create function f1()
returns void as $$
begin
  execute '';
end;
$$ language plpgsql;

select * from plpgsql_check_function('dynamic_emptystr()');

select f1();

the server crashes.

Coredump:

(gdb) bt
#0  0x00007fa609f259fc in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007fa609ed1476 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007fa609eb77f3 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000561930ff3890 in ExceptionalCondition (conditionName=<optimized out>, fileName=<optimized out>, 
    lineNumber=<optimized out>) at assert.c:66
#4  0x00007fa5fec1de43 in list_nth_cell (list=0x0, n=0) at ../../src/include/nodes/pg_list.h:279
#5  0x00007fa5fec21086 in profiler_get_dyn_queryid (estate=0x7ffc194ddce0, expr=0x5619333c6cd0, qparams=0x0)
    at src/profiler.c:1658
#6  0x00007fa5fec213fa in profiler_get_queryid (estate=0x7ffc194ddce0, stmt=0x5619333c7750, 
    has_queryid=0x5619333bd620, qparams=0x5619333bd628) at src/profiler.c:1766
#7  0x00007fa5fec22724 in profiler_stmt_end (estate=0x7ffc194ddce0, stmt=0x5619333c7750, 
    plugin2_info=0x5619333bd3f8) at src/profiler.c:2270
#8  0x00007fa5fec1c02d in pldbgapi2_stmt_end (estate=0x7ffc194ddce0, stmt=0x5619333c7750)
    at src/pldbgapi2.c:1244
#9  0x00007fa5fec5593b in exec_stmts (estate=0x7ffc194ddce0, stmts=0x5619333c77a0) at pl_exec.c:2132
#10 0x00007fa5fec57e6b in exec_stmt_block (estate=0x7ffc194ddce0, block=0x5619333c77f0) at pl_exec.c:1943
#11 0x00007fa5fec57f7d in exec_toplevel_block (estate=estate@entry=0x7ffc194ddce0, block=0x5619333c77f0)
    at pl_exec.c:1634
#12 0x00007fa5fec58881 in plpgsql_exec_function (func=func@entry=0x5619332e64d8, fcinfo=fcinfo@entry=0x5619333bcaf8, simple_eval_estate=simple_eval_estate@entry=0x0, simple_eval_resowner=simple_eval_resowner@entry=0x0, procedure_resowner=procedure_resowner@entry=0x0, atomic=<optimized out>) at pl_exec.c:623
#13 0x00007fa5fec6301b in plpgsql_call_handler (fcinfo=0x5619333bcaf8) at pl_handler.c:277
#14 0x0000561930ffcce0 in fmgr_security_definer (fcinfo=0x5619333bcaf8) at fmgr.c:747
#15 0x0000561930cd7a23 in ExecInterpExpr (state=0x5619333bc9a0, econtext=0x5619333bc748, isnull=<optimized out>) at execExprInterp.c:740
#16 0x0000561930d10d4c in ExecEvalExprSwitchContext (isNull=0x7ffc194de1a7, econtext=0x5619333bc748, state=0x5619333bc9a0) at ../../../src/include/executor/executor.h:356
#17 ExecProject (projInfo=0x5619333bc998) at ../../../src/include/executor/executor.h:390
#18 ExecResult (pstate=<optimized out>) at nodeResult.c:135
#19 0x0000561930cdc6aa in ExecProcNode (node=0x5619333bc638) at ../../../src/include/executor/executor.h:274
#20 ExecutePlan (execute_once=<optimized out>, dest=0x5619333c0c08, direction=<optimized out>, numberTuples=0, sendTuples=<optimized out>, operation=CMD_SELECT, use_parallel_mode=<optimized out>, planstate=0x5619333bc638, estate=0x5619333bc410) at execMain.c:1646
#21 standard_ExecutorRun (queryDesc=0x561933390610, direction=<optimized out>, count=0, execute_once=<optimized out>) at execMain.c:363
#22 0x0000561930eb05ef in PortalRunSelect (portal=0x561933328930, forward=<optimized out>, count=0, dest=<optimized out>) at pquery.c:924
#23 0x0000561930eb1cd1 in PortalRun (portal=portal@entry=0x561933328930, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x5619333c0c08, altdest=altdest@entry=0x5619333c0c08, qc=0x7ffc194de440) at pquery.c:768
#24 0x0000561930eadb87 in exec_simple_query (query_string=0x5619332ab540 "select f1();") at postgres.c:1278
#25 0x0000561930eaf748 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4743
#26 0x0000561930ea9e73 in BackendMain (startup_data=<optimized out>, startup_data_len=<optimized out>) at backend_startup.c:105
#27 0x0000561930e07879 in postmaster_child_launch (child_type=child_type@entry=B_BACKEND, startup_data=startup_data@entry=0x7ffc194de8e0 "", startup_data_len=startup_data_len@entry=4, client_sock=client_sock@entry=0x7ffc194de900) at launch_backend.c:277
#28 0x0000561930e0b5d5 in BackendStartup (client_sock=0x7ffc194de900) at postmaster.c:3593
#29 ServerLoop () at postmaster.c:1674
#30 0x0000561930e0d337 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x5619332a5bd0) at postmaster.c:1372
#31 0x0000561930affe5a in main (argc=3, argv=0x5619332a5bd0) at main.c:197

Postgres version:

postgres=# select version();
                                                version                                                
-------------------------------------------------------------------------------------------------------
 PostgreSQL 16.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
(1 row)

plpgsql_check version:

postgres=# \dx plpgsql_check 
                      List of installed extensions
     Name      | Version | Schema |             Description              
---------------+---------+--------+--------------------------------------
 plpgsql_check | 2.7     | public | extended check for plpgsql functions
(1 row)

commit: 9dcdedc

Best regards,
Nikita Kalinin
Postgres Professional

should be fixed by d694606

please, check

Yeah. That fixed the problem. I'm closing the issue. Thank you!