public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tatsuo Ishii <[email protected]>
To: [email protected]
Subject: pgpool: Fix segfault with CopyOut.
Date: Sun, 16 Nov 2025 07:17:55 +0000
Message-ID: <[email protected]> (raw)
Fix segfault with CopyOut.
When "COPY relname TO STDOUT" is executed in the extended query
protocol mode, pgpool segfaulted.
When read_kind_from_backend() reads a message from backend, it
extracts the corresponding entry from the pending message queue when
processing extended query protocol messages. However, if the head of
the message queue is an "execute" message, some of incoming message
types are exceptional because other than CommandComplete message
(which means the execute message finishes) may come from backend. This
includes DataRow, ErrorResponse, NoticeMessage. Unfortunately we
overlooked that 'H' (CopyOutResponse) is in the group too. Thus when
CopyOutResponse comes from backend, the execute pending message is
removed. If the next message from frontend is Sync (it's often
happens), read_kind_from_backend() sets session_context->query_context
to NULL, and calls pool_unset_query_in_progress(), which accesses
session_context->query_context and segfaults.
The fix is, to add CopyOutResponse to the exception list. Just in
case, we also add 'd' (CopyData) and 'c' (CopyDone) to the list. This
may not be actually necessary since CopyData and CopyDone are
processced in CopyDataRows() though.
Add regression test case to 126.copy_hang (master and v4.7) or
076.copy_hang (v4.6 or before).
Author: Tatsuo Ishii <[email protected]>
Reported-by: https://github.com/tetesh
Reviewed-by: Bo Peng <[email protected]>
Discussion: https://github.com/pgpool/pgpool2/issues/133
Backpatch-through: v4.2
Branch
------
V4_4_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=83102f6d5513026493c0edc9e93e82ebef451...
Modified Files
--------------
src/protocol/pool_process_query.c | 11 ++++---
.../tests/076.copy_hang/copy-out-expected | 37 ++++++++++++++++++++++
.../tests/076.copy_hang/pgproto-copy-out.data | 9 ++++++
src/test/regression/tests/076.copy_hang/test.sh | 16 ++++++++++
4 files changed, 69 insertions(+), 4 deletions(-)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: pgpool: Fix segfault with CopyOut.
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox