]> 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:35 +0000 (19:10 +0300)
commit79f17d45e82f3648c2459b8128ab4d516fb7640a
tree409f59cb2a151a042068477536ef6a6098ad3f62
parenta3deecb1c9af1e3d210a321401e40f22db859290
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