postgres.git / summary / log / commit / refs

commit    208e262f9246df9050aee63a933bb8b7fe265163
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Mon Jan 20 17:57:17 2020 +0000
First released in: 13.0, 9.4.26, 9.5.21, 9.6.17, 10.12, 11.7, 12.2

    Fix pg_dump's sigTermHandler() to use _exit() not exit().
    
    sigTermHandler() tried to be careful to invoke only operations that
    are safe to do in a signal handler.  But for some reason we forgot
    that exit(3) is not among those, because it calls atexit handlers
    that might do various random things.  (pg_dump itself installs no
    atexit handlers, but e.g. OpenSSL does.)  That led to crashes or
    lockups when attempting to terminate a parallel dump or restore
    via a signal.
    
    Fix by calling _exit() instead.
    
    Per bug #16199 from Raúl Marín.  Back-patch to all supported branches.
    
    Discussion: https://postgr.es/m/16199-cb2f121146a96f9b@postgresql.org


src/bin/pg_dump/parallel.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c index bfd023f3e1f..c914c26149f 100644 --- a/src/bin/pg_dump/parallel.c +++ b/src/bin/pg_dump/parallel.c @@ -574,8 +574,11 @@ sigTermHandler(SIGNAL_ARGS) write_stderr("terminated by user\n"); } - /* And die. */ - exit(1); + /* + * And die, using _exit() not exit() because the latter will invoke atexit + * handlers that can fail if we interrupted related code. + */ + _exit(1); } /* [parent: e96f30d898d8]