[pgpool-committers: 8812] 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:41 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
------
V4_0_STABLE

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

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



More information about the pgpool-committers mailing list