public inbox for [email protected]  
help / color / mirror / Atom feed
From: Euler Taveira <[email protected]>
To: Michael Paquier <[email protected]>
To: Postgres hackers <[email protected]>
Cc: Álvaro Herrera <[email protected]>
Subject: Re: NULL pointer dereference in syslogger with load_libraries() and -DEXEC_BACKEND at startup
Date: Mon, 25 May 2026 23:39:54 -0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>

On Mon, May 25, 2026, at 5:21 AM, Michael Paquier wrote:
> On Mon, May 25, 2026 at 04:45:41PM +0900, Michael Paquier wrote:
>> I did not take the cycles necessary for a bisect, but it looks like
>> this has been around for a few months at least.  I have pinged
>> f3c9e341cdf1 as a safe startup point for now, so that's a 2026 issue.
>
> Well, well:
> 0c8e082fba8d36434552d3d7800abda54acafd57 is the first bad commit 
> committer: Álvaro Herrera <[email protected]>
> date: Wed, 4 Feb 2026 16:56:57 +0100
> Assign "backend" type earlier during process start-up 
>
> I have also checked manually a revert of this commit, and saw that the
> problem is gone, so it does not look like I have messed up my bisect.
>

It seems I was too optimistic about this patch. Since the commit 0c8e082fba8
sets MyBackendType to B_LOGGER earlier, it breaks the following assumption in
syslogger.c.

        /*
         * If we're told to write to a structured log file, but it's not open,
         * dump the data to syslogFile (which is always open) instead.  This can
         * happen if structured output is enabled after postmaster start and we've
         * been unable to open logFile.  There are also race conditions during a
         * parameter change whereby backends might send us structured output
         * before we open the logFile or after we close it.  Writing formatted
         * output to the regular log file isn't great, but it beats dropping log
         * output on the floor.

It shouldn't assume syslogFile is always open. The send_message_to_server_log()
shouldn't be executing the following code path in this case.

    /* If in the syslogger process, try to write messages direct to file */
    if (MyBackendType == B_LOGGER)
        write_syslogger_file(buf.data, buf.len, LOG_DESTINATION_STDERR);

It could set MyBackendType only if child_type != B_LOGGER during
launch_backend.c and set it at the same code path as in the past. However, I
consider this solution ugly and hackish.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/






reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: NULL pointer dereference in syslogger with load_libraries() and -DEXEC_BACKEND at startup
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox