[pgpool-committers: 8811] pgpool: Fix rare segfaults in pcp_proc_info, SHOW pool_pools and SHOW p

Tatsuo Ishii ishii at sraoss.co.jp
Fri Sep 23 19:40:35 JST 2022


Fix rare segfaults in pcp_proc_info, SHOW pool_pools and SHOW pool_processes.

The segfaults were in get_pools() and get_processes(). They first
extracted pid of particular process info slot on shared memory then
searched the slot again by using pid as the key. Because these steps
were not protected by any locking, it was possible that the search
using the pid failed and returned NULL if the process id is
overwritten by pgpool parent which is responsible for forking new
child process after the process exiting. As a result any subsequent
reference to the NULL pointer generated segfaults.

Solution is, first get the pointer to the process info slot then
extract the process id member from the pointer. This way, still
concurrent updating to the shared memory info by the parent process is
possible (which may lead to strange results in the output) but at
least we can avoid segfaults.

Branch
------
V3_7_STABLE

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

Modified Files
--------------
src/utils/pool_process_reporting.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)



More information about the pgpool-committers mailing list