On master with the v54 patches applied the following script leads to crash: export ASAN_OPTIONS=detect_leaks=0:abort_on_error=1:disable_coredump=0:strict_string_checks=1:check_initialization_order=1:strict_init_order=1 initdb -D data pg_ctl -w -t 5 -D data -l server.log start psql -c "create global temp table tmp_table_test_statistics(a int); insert into temp_table_test_statistics values(generate_series(1,1000000000));" & sleep 1 pg_ctl -w -t 5 -D data -l server.log stop
and i got error ================================================================= ==1022892==ERROR: AddressSanitizer: heap-use-after-free on address 0x62500004c640 at pc 0x562435348750 bp 0x7ffee8487e60 sp 0x7ffee8487e50 READ of size 8 at 0x62500004c640 thread T0 --- with backtrace: Core was generated by `postgres: andrew regression [local] INSERT '. Program terminated with signal SIGABRT, Aborted. #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007fa8fd008859 in __GI_abort () at abort.c:79 #2 0x000056243471eae2 in __sanitizer::Abort() () #3 0x000056243472968c in __sanitizer::Die() () #4 0x000056243470ad1c in __asan::ScopedInErrorReport::~ScopedInErrorReport() () #5 0x000056243470a793 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) () #6 0x000056243470b5db in __asan_report_load8 () #7 0x0000562435348750 in DropRelFileNodesAllBuffers (smgr_reln=smgr_reln@entry=0x62500004c640, nnodes=nnodes@entry=1) at bufmgr.c:3211 #8 0x00005624353ec8a8 in smgrdounlinkall (rels=rels@entry=0x62500004c640, nrels=nrels@entry=1, isRedo=isRedo@entry=false) at smgr.c:397 #9 0x0000562434aa76e1 in gtt_storage_removeall (code=<optimized out>, arg=<optimized out>) at storage_gtt.c:726 #10 0x0000562435371962 in shmem_exit (code=code@entry=1) at ipc.c:236 #11 0x0000562435371d4f in proc_exit_prepare (code=code@entry=1) at ipc.c:194 #12 0x0000562435371f74 in proc_exit (code=code@entry=1) at ipc.c:107 #13 0x000056243581e35c in errfinish (filename=<optimized out>, filename@entry=0x562435b800e0 "postgres.c", lineno=lineno@entry=3191, funcname=funcname@entry=0x562435b836a0 <__func__.26025> "ProcessInterrupts") at elog.c:666 #14 0x00005624353f5f86 in ProcessInterrupts () at postgres.c:3191 #15 0x0000562434eb26d6 in ExecProjectSet (pstate=0x62500003f150) at nodeProjectSet.c:51 #16 0x0000562434eaae8e in ExecProcNode (node=0x62500003f150) at ../../../src/include/executor/executor.h:257 #17 ExecModifyTable (pstate=0x62500003ec98) at nodeModifyTable.c:2429 #18 0x0000562434df5755 in ExecProcNodeFirst (node=0x62500003ec98) at execProcnode.c:463 #19 0x0000562434dd678a in ExecProcNode (node=0x62500003ec98) at ../../../src/include/executor/executor.h:257 #20 ExecutePlan (estate=estate@entry=0x62500003ea20, planstate=0x62500003ec98, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_INSERT, sendTuples=false, numberTuples=numberTuples@entry=0, direction=ForwardScanDirection, dest=0x625000045550, execute_once=true) at execMain.c:1555 #21 0x0000562434dd9867 in standard_ExecutorRun (queryDesc=0x6190000015a0, direction=ForwardScanDirection, count=0, execute_once=execute_once@entry=true) at execMain.c:361 #22 0x0000562434dd9a83 in ExecutorRun (queryDesc=queryDesc@entry=0x6190000015a0, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:305 #23 0x0000562435401be6 in ProcessQuery (plan=plan@entry=0x625000045480, sourceText=0x625000005220 "insert into temp_table_test_statistics values(generate_series(1,1000000000));", params=0x0, queryEnv=0x0, dest=dest@entry=0x625000045550, qc=qc@entry=0x7ffee84886d0) at pquery.c:160 #24 0x0000562435404a32 in PortalRunMulti (portal=portal@entry=0x625000020a20, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=false, dest=dest@entry=0x625000045550, altdest=altdest@entry=0x625000045550, qc=qc@entry=0x7ffee84886d0) at pquery.c:1274 #25 0x000056243540598d in PortalRun (portal=portal@entry=0x625000020a20, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x625000045550, altdest=altdest@entry=0x625000045550, qc=<optimized out>) at pquery.c:788 #26 0x00005624353fa917 in exec_simple_query (query_string=query_string@entry=0x625000005220 "insert into temp_table_test_statistics values(generate_series(1,1000000000));") at postgres.c:1214 #27 0x00005624353ff61d in PostgresMain (dbname=dbname@entry=0x629000011278 "regression", username=username@entry=0x629000011258 "andrew") at postgres.c:4497 #28 0x00005624351f65c7 in BackendRun (port=port@entry=0x615000002d80) at postmaster.c:4560 #29 0x00005624351ff1c5 in BackendStartup (port=port@entry=0x615000002d80) at postmaster.c:4288 #30 0x00005624351ff970 in ServerLoop () at postmaster.c:1801 #31 0x0000562435201da4 in PostmasterMain (argc=3, argv=<optimized out>) at postmaster.c:1473 #32 0x0000562434f3ab2d in main (argc=3, argv=0x603000000280) at main.c:198 --- I've built the server with sanitizers using gcc 9 as following: CPPFLAGS="-Og -fsanitize=address -fsanitize=undefined -fno-sanitize=nonnull-attribute -fno-sanitize-recover -fno-sanitize=alignment -fstack-protector" LDFLAGS='-fsanitize=address -fsanitize=undefined -static-libasan' ./configure --enable-tap-tests --enable-debug