pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: tgl@sss.pgh.pa.us
Cc: andres@anarazel.de
Cc: vignesh21@gmail.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: initdb SegFault
Date: Wed, 20 Nov 2019 11:11:16 +0900 (JST)
Message-ID: <20191120.111116.481406309940778474.horikyota.ntt@gmail.com> (raw)
In-Reply-To: <19334.1574183210@sss.pgh.pa.us>
References: <7379.1574176562@sss.pgh.pa.us>
	<20191119161059.6styj2huulh4zrkw@alap3.anarazel.de>
	<19334.1574183210@sss.pgh.pa.us>

At Tue, 19 Nov 2019 12:06:50 -0500, Tom Lane <tgl@sss.pgh.pa.us> wrote in 
> Andres Freund <andres@anarazel.de> writes:
> > Agreed wrt this specific failure scenario. It does however seem not
> > great that callsites for PQExpBuffer ought to check every call for
> > allocation failures, in the general case.
> 
> It is possible to check just once at the end, using the PQExpBufferBroken
> API, and I believe that libpq for instance is fairly careful about that.

FWIW, I looked though the callers of PQExpBuffer.

pqGetErrorNotice3 seems ingoring OOM on message buffer when !isError,
then sets NULL to res->errMsg. getParameterStatus doesn't check that
before use, too.

Most of the callers of PQExpBufferDataBroken use libpq_gettext("out of
memory"). And some of them do strdup(libpq_gettext()).

Not restricting to libpq functions, 

dblink_connstr_check complains as "password is required" when
PQconninfoParse hits OOM.

libpqrcv_check_conninfo() will show '(null)' or maybe get SEGV on some
platforms when PQconninfoParse() hits OOM, since it uses err without
null checking. pg_basebackup, pg_dumpall and pg_isready is doing the
same thing.


> I agree that programs that just need to print something and exit could
> perhaps ask pqexpbuffer.c to handle that for them.  (But initdb still
> doesn't fall in that category, because of its very nontrivial atexit
> handler :-(.)
> 
> > I wonder if, for frontend paths, a simplified error handling path would
> > be worthwhile for OOM paths. Doing only a write() or such to print an
> > error message.
> 
> Perhaps.  You wouldn't get any translation --- but then, gettext is
> probably going to fail anyway under such conditions.

I think we should refrain from translating in the cases.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center





view thread (5+ messages)

Message-ID: <20191120.111116.481406309940778474.horikyota.ntt@gmail.com>
Permalink:  ../20191120.111116.481406309940778474.horikyota.ntt@gmail.com/
Also on:    postgresql.org/message-id/20191120.111116.481406309940778474.horikyota.ntt@gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: horikyota.ntt@gmail.com, tgl@sss.pgh.pa.us, andres@anarazel.de, vignesh21@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: initdb SegFault
  In-Reply-To: <20191120.111116.481406309940778474.horikyota.ntt@gmail.com>
  References: <7379.1574176562@sss.pgh.pa.us> <20191119161059.6styj2huulh4zrkw@alap3.anarazel.de> <19334.1574183210@sss.pgh.pa.us> <20191120.111116.481406309940778474.horikyota.ntt@gmail.com>

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

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