Install system exit callback only after initialization of shared memory.
authorMuhammad Usama <m.usama@gmail.com>
Sun, 23 Jul 2023 17:34:05 +0000 (22:34 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Sun, 23 Jul 2023 17:41:45 +0000 (22:41 +0500)
commitbbbcd3ac5dc752a928eb4275d3cb64bdb54a1b73
tree2f1c4c6022e2a31d237d50d7b0200bf37aa38386
parent212c9b87261eb0099a6ccd5fbff25ed8c41f10c6
Install system exit callback only after initialization of shared memory.

When the on-exit callback gets called because of a failure to acquire
shared memory. The cleanup function can produce a segfault while accessing
process_info, that lives in shared memory.
Although we can also fix this by bailing out from the exit callback when
process_info is NULL but installing the function after successful initialization
of shared memory is a better approach as the rest of the system always assumes
the process_info can never be NULL, and also, there is nothing to
clean up before child processes are spawned.
src/main/pgpool_main.c