[pgpool-committers: 7583] pgpool: Fix pgpool crash when query cache enabled.

Tatsuo Ishii ishii at sraoss.co.jp
Fri Apr 9 20:45:20 JST 2021


Fix pgpool crash when query cache enabled.

Pgpool-II crashed upon receiving CloseComplete.
This only happened in other than streaming and logical replication mode.

The minimum test case is as follows:

'P'     "S1"    "SELECT 1"      0
'B'     "P1"    "S1"    0       0       0
'E'     "P1"    0
'C'     'P'     "P1"
'B'     "P2"    "S1"    0       0       0
'E'     "P2"    0
'C'     'P'     "P2"
'S'
'Y'
'X'

A query statement S1 is bound to portal P1 and P1 is closed. When
CommandComplete message arrives, CloseComplete() discard temp query
cache buffer corresponding to the query context. Unfortunately it
forgot to set NULL to query_context->temp_cache. So whnen next time
other portal P2 which was also bound to S1 is closed, CloseComplete()
tries to free memory which was already freed by previous
CloseComplete. This leads to a segfault.

Fix is set NULL to query_context->temp_cache when the CloseComplete()
is called.

The reason why in streaming and logical replication this does occur
is, unlike other mode, in these mode query_context->temp_cache is
already freed and set to NULL when CommandComplete arrives.

Also new regression test
074.bug700_memqcache_bug_segfault_at_close_complete is added.

Per bug 700.

Branch
------
V3_7_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=c22db3ea0070e59bf7d91a3672b0aedcde235664

Modified Files
--------------
src/protocol/pool_proto_modules.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)



More information about the pgpool-committers mailing list