Don't run atexit callbacks in quickdie signal handlers.
authorHeikki Linnakangas <[email protected]>
Wed, 8 Aug 2018 16:08:10 +0000 (19:08 +0300)
committerHeikki Linnakangas <[email protected]>
Wed, 8 Aug 2018 16:09:30 +0000 (19:09 +0300)
commit2332020d6d1912bff4c03a8c2b37ad1c8b184281
treeb40e47542a55953bd2529bfd80af6233272aca99
parent9446d7157740a09613175209c9e4eef02d3d92db
Don't run atexit callbacks in quickdie signal handlers.

exit() is not async-signal safe. Even if the libc implementation is, 3rd
party libraries might have installed unsafe atexit() callbacks. After
receiving SIGQUIT, we really just want to exit as quickly as possible, so
we don't really want to run the atexit() callbacks anyway.

The original report by Jimmy Yih was a self-deadlock in startup_die().
However, this patch doesn't address that scenario; the signal handling
while waiting for the startup packet is more complicated. But at least this
alleviates similar problems in the SIGQUIT handlers, like that reported
by Asim R P later in the same thread.

Backpatch to 9.3 (all supported versions).

Discussion: https://www.postgresql.org/message-id/CAOMx_OAuRUHiAuCg2YgicZLzPVv5d9_H4KrL_OFsFP%3DVPekigA%40mail.gmail.com
src/backend/postmaster/bgworker.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/startup.c
src/backend/postmaster/walwriter.c
src/backend/replication/walreceiver.c
src/backend/tcop/postgres.c