[pgpool-committers: 9960] pgpool: Fix segfault to not use MAIN_NODE macro.

Tatsuo Ishii ishii at sraoss.co.jp
Fri Jun 21 16:21:10 JST 2024


Fix segfault to not use MAIN_NODE macro.

Some functions (close_idle_connection(), new_connection() and
pool_create_cp()) used MAIN* and VALID_BACKEND where they are not
appropriate. MAIN* and VALID_BACKEND are only useful against current
connections to backend, not for pooled connections since in pooled
connections which backend is the main node or up and running is
necessarily same as the current connections to backend.
The misuses of those macros sometimes leads to segfault.

This patch introduces new in_use_backend_id() which returns the fist
node id in use. This commit replaces some of MAIN* with the return
value from in_use_backend_id(). Also inappropriate calls to
VALID_BACKEND are replaced with CONNECTION_SLOT macro.

Problem reported by Emond Papegaaij
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2024-June/009176.html
[pgpool-general: 9114] Re: Another segmentation fault
Backpatch-through: V4.1

Branch
------
V4_1_STABLE

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

Modified Files
--------------
src/protocol/child.c                | 34 ++++++++++---------------
src/protocol/pool_connection_pool.c | 50 ++++++++++++++++++++++++++++---------
2 files changed, 51 insertions(+), 33 deletions(-)



More information about the pgpool-committers mailing list