Segmentation error in hash_bytes function due to null pointer passed to hash_search during execution of plpgsql_check_is_checked
nkPit opened this issue · 4 comments
nkPit commented
Hello!
After executing the following query:
load 'plpgsql_check';
set plpgsql_check.mode = 'fresh_start';
do $$
declare
begin
end;
$$;
the server crashes.
coredump:
#0 hash_bytes (k=<optimized out>, keylen=<optimized out>) at hashfn.c:167
167 b += ka[1];
(gdb) bt
#0 hash_bytes (k=<optimized out>, keylen=<optimized out>) at hashfn.c:167
#1 0x000056423c8dfaa4 in hash_search (hashp=0x56423e90fc58, keyPtr=0x0,
action=HASH_FIND, foundPtr=0x0) at dynahash.c:958
#2 0x00007f9619dc64a4 in plpgsql_check_is_checked (func=0x56423e923490)
at src/check_function.c:1378
#3 0x00007f9619dc35c6 in passive_check_func_beg (estate=0x7ffc7d095f60,
func=0x56423e923490, plugin2_info=0x56423e8690d0) at src/check_function.c:321
#4 0x00007f9619dd2ff6 in pldbgapi2_func_beg (estate=0x7ffc7d095f60,
func=0x56423e923490) at src/pldbgapi2.c:974
#5 0x00007f9619d998d5 in plpgsql_exec_function (func=func@entry=0x56423e923490,
fcinfo=fcinfo@entry=0x7ffc7d096120,
simple_eval_estate=simple_eval_estate@entry=0x56423e92b9f8,
simple_eval_resowner=simple_eval_resowner@entry=0x56423e879818,
procedure_resowner=procedure_resowner@entry=0x56423e879818,
atomic=<optimized out>) at pl_exec.c:617
#6 0x00007f9619da39cd in plpgsql_inline_handler (fcinfo=<optimized out>) at pl_handler.c:368
#7 0x000056423c8d98f1 in fmgr_security_definer (fcinfo=0x7ffc7d0963a0) at fmgr.c:718
#8 0x000056423c8da4e4 in FunctionCall1Coll (flinfo=0x7ffc7d0963f0, collation=<optimized out>, arg1=<optimized out>) at fmgr.c:1110
#9 0x000056423c8dac13 in OidFunctionCall1Coll (functionId=<optimized out>, collation=collation@entry=0, arg1=94842516835000, arg1@entry=281479271691499) at fmgr.c:1388
#10 0x000056423c578bf6 in ExecuteDoStmt (pstate=0x56423e869398, pstate@entry=0x56423e8689a8, stmt=stmt@entry=0x56423e83f008, atomic=atomic@entry=false) at functioncmds.c:2145
#11 0x000056423c799826 in standard_ProcessUtility (pstmt=0x56423e83f0a8, queryString=0x56423e83e538 "do $$\ndeclare\nbegin\nend;\n$$;", readOnlyTree=<optimized out>, context=PROCESS_UTILITY_TOPLEVEL, params=0x0, queryEnv=0x0, dest=0x56423e83f368, qc=0x7ffc7d096740) at utility.c:714
#12 0x000056423c797e11 in PortalRunUtility (portal=portal@entry=0x56423e8bbd68, pstmt=pstmt@entry=0x56423e83f0a8, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x56423e83f368, qc=qc@entry=0x7ffc7d096740) at pquery.c:1158
#13 0x000056423c797f4d in PortalRunMulti (portal=portal@entry=0x56423e8bbd68, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x56423e83f368, altdest=altdest@entry=0x56423e83f368, qc=qc@entry=0x7ffc7d096740) at pquery.c:1315
#14 0x000056423c7985e1 in PortalRun (portal=portal@entry=0x56423e8bbd68, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x56423e83f368, altdest=altdest@entry=0x56423e83f368, qc=0x7ffc7d096740) at pquery.c:791
#15 0x000056423c7943a4 in exec_simple_query (query_string=0x56423e83e538 "do $$\ndeclare\nbegin\nend;\n$$;") at postgres.c:1274
#16 0x000056423c795f49 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:4637
#17 0x000056423c6fd45f in BackendRun (port=0x56423e86b300, port=0x56423e86b300) at postmaster.c:4464
#18 BackendStartup (port=0x56423e86b300) at postmaster.c:4192
#19 ServerLoop () at postmaster.c:1782
#20 0x000056423c6fe483 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x56423e838bb0) at postmaster.c:1466
#21 0x000056423c4074a1 in main (argc=3, argv=0x56423e838bb0) at main.c:198
Postgres version:
postgres=# select version();
version
-------------------------------------------------------------------------------------------------------
PostgreSQL 16.3 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: 43bfbe5
Best regards,
Nikita Kalinin
Postgres Professional
nkPit commented
Postgres has been compiled like this:
./configure --enable-debug --enable-tap-tests --enable-cassert --with-icu
nkPit commented
Yes, everything works. Thank you.
okbob commented
Thank you for report