]> granicus.if.org Git - postgresql/commit
Don't run atexit callbacks in quickdie signal handlers.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Aug 2018 16:08:10 +0000 (19:08 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Aug 2018 16:10:32 +0000 (19:10 +0300)
commit8e19a82640d3fa2350db146ec72916856dd02f0a
tree312824322119d8dede7f64845eda3c463c7d2778
parent11e22e486d8da6cef4d954c6f2952097df276fa7
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