Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to - Mailing list pgsql-patches

From Tom Lane
Subject Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to
Date
Msg-id 9091.1138739163@sss.pgh.pa.us
Whole thread Raw
In response to Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to
List pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> The problem is that for EXEC_BACKEND, which is the default for WIN32 and
> what I used for testing, progname is NULL because we do not set it after
> the fork/exec.  Most versions of printf report "(null)" for a null
> argument to printf("%s"), but our port/snprintf.c version aborts, which
> is probably better in terms of finding bugs.

Good catch.

> The attached patch fixes the problem by setting progname early in
> main(), like we do for all other applications.

It'd probably be best to strdup() argv[0], because of the likelihood
that the argv area will get clobbered at some point by ps_status.c.
It was OK to have a private static in postmaster.c, because the
postmaster doesn't ever call ps_status.c, but if we are going to expose
the variable in child processes it needs to be more globally valid.

I see that get_progname strdup's its argument in some cases but not
all --- so simplest fix is to make it always do so.

            regards, tom lane

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to
Next
From: Bruce Momjian
Date:
Subject: Re: [BUGS] BUG #2195: log_min_messages crash server when in DEBUG3 to