Install system exit callback only after initialization of shared memory.
authorMuhammad Usama <m.usama@gmail.com>
Sun, 23 Jul 2023 17:52:46 +0000 (22:52 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Sun, 23 Jul 2023 17:57:02 +0000 (22:57 +0500)
commitaa15b3ccf11543120b682c604f44acfdf62df789
tree7ea35c1286e3123d59d677bc18c79ca4e629363a
parent69a18d05d8a2e90a7d1a50e6a700bee5af34efc0
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. Also, there is nothing to
clean up before child processes are spawned.
src/main/pgpool_main.c