Segment fault when excuting SPI function On PG with commit 41c6a5be - Mailing list pgsql-hackers

From liuhuailing@fujitsu.com
Subject Segment fault when excuting SPI function On PG with commit 41c6a5be
Date
Msg-id OSZPR01MB6215671E3C5956A034A080DFBEEC9@OSZPR01MB6215.jpnprd01.prod.outlook.com
Whole thread Raw
Responses Re: Segment fault when excuting SPI function On PG with commit 41c6a5be  (Greg Nancarrow <gregn4422@gmail.com>)
Re: Segment fault when excuting SPI function On PG with commit 41c6a5be  (Ranier Vilela <ranier.vf@gmail.com>)
Re: Segment fault when excuting SPI function On PG with commit 41c6a5be  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Hi, all

When I used SPI_execute_plan function on PG12 which commit 41c6a5be is used,
Segment fault occurred.

PS: If commit 41c6a5be is not used, this phenomenon will not happen. 

Reproduce:
In a background process, the following steps are executed.
--------------------------
StartTransactionCommand();
SPI_connect();       
plan = SPI_prepare(query,0,NULL); ★the query is a SELECT SQL. 
SPI_keepplan(plan);         
SPI_finish();           
CommitTransactionCommand();   
StartTransactionCommand();    
SPI_connect();
SPI_execute_plan(plan, NULL, NULL, true, 0); ★Segment fault
--------------------------

Core stack:
Stack trace of thread 43926:
                #0  0x0000000000772f19 EnsurePortalSnapshotExists (postgres)
                #1  0x000000000064f85c _SPI_execute_plan (postgres)
                #2  0x000000000064fbd1 SPI_execute_plan (postgres)
                #3  0x00007fbee784402e xxx (xxx.so)
                #4  0x00007fbee78424ae xxxx (xxxx.so)
                #5  0x00000000006e91f5 StartBackgroundWorker (postgres)
                #6  0x00000000006f5e25 maybe_start_bgworkers (postgres)
                #7  0x00000000006f6121 reaper (postgres)
                #8  0x00007fbeedf48dc0 __restore_rt (libpthread.so.0)
                #9  0x00007fbeebadf75b __select (libc.so.6)
                #10 0x00000000006f6ea6 ServerLoop (postgres)
                #11 0x00000000006f8c30 PostmasterMain (postgres)
                #12 0x0000000000485d99 main (postgres)
                #13 0x00007fbeeba0f873 __libc_start_main (libc.so.6)
                #14 0x0000000000485e3e _start (postgres)

Is there a bug in the commit 41c6a5be?  Please confirm it.

Regards, Liu Huailing


pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: Background writer and checkpointer in crash recovery
Next
From: Daniel Gustafsson
Date:
Subject: Re: Slightly improve initdb --sync-only option's help message