Re: [HACKERS] ERROR: infinite recursion in proc_exit

Bruce Momjian <maillist@candle.pha.pa.us>

From: Bruce Momjian <maillist@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Massimo Dal Zotto <dz@cs.unitn.it>, PostgreSQL Hackers <hackers@postgreSQL.org>
Date: 1999-11-06T19:45:37Z
Lists: pgsql-hackers
> That isn't going to make things any better, because it's still laboring
> under the same basic oversight: elog(ERROR) does not return to the
> caller, it returns control to the main loop.  Thus, having proc_exit
> call elog(ERROR) is simply *guaranteed* to create a failure.  proc_exit
> must not allow control to return anywhere, under any circumstances,
> because it is used as the final recourse when things are too screwed up
> to consider continuing.

Massimo pointed out some problems in my fix.  The new code is:

    if (++proc_exit_inprogress == 9)  
        elog(ERROR, "infinite recursion in proc_exit");
    if (proc_exit_inprogress >= 9)
        goto exit;
    
    /* ----------------
     *  if proc_exit_inprocess > 1, then it means that we
     *  are being invoked from within an on_exit() handler
     *  and so we return immediately to avoid recursion.  
     * ----------------
     */
    if (proc_exit_inprogress > 1)  
        return;

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026