pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksander Alekseev <a.alekseev@postgrespro.ru>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: Missing checks when malloc returns NULL...
Date: Tue, 30 Aug 2016 16:30:49 +0300
Message-ID: <20160830133048.GA84635@e733> (raw)
In-Reply-To: <CAB7nPqRDbjezFe_AeA8zYVqx20yZwW9n3Aj93KO5485D2G8BHA@mail.gmail.com>
References: <7978.1466516782@sss.pgh.pa.us>
	<CAB7nPqRRR8mnM9kbGObV2tzP-BpmLotiKyVBPbY2bxjuAyeCpw@mail.gmail.com>
	<d4b09f6b-06b9-2678-a0f8-714e3468b9eb@iki.fi>
	<CAB7nPqQhEF854DuLPaqpx+FfrY3YEcqYTVa12YKXMk_ayCtqqQ@mail.gmail.com>
	<CAB7nPqSCxBWt7Q1dpFTekg-zDx_GZ-ELgEOfYJ47zrD8=v=yHg@mail.gmail.com>
	<20160829130513.GA8340@e733>
	<20160829141315.GB8340@e733>
	<CAB7nPqSaEQPSXusCEqT=dsB3rpSA=k7EQVxCu63y8N4URmV3CA@mail.gmail.com>
	<24843.1472563085@sss.pgh.pa.us>
	<CAB7nPqRDbjezFe_AeA8zYVqx20yZwW9n3Aj93KO5485D2G8BHA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

> > I think what we ought to do is make ShmemAlloc act like palloc
> > (ie throw error not return NULL), and remove the duplicated error
> > checks.  For the one caller that that would be bad for, we could
> > invent something like ShmemAllocNoError, or ShmemAllocExtended with
> > a no_error flag, or whatever other new API suits your fancy.  But
> > as-is, it's just inviting more errors-of-omission like the large
> > number that already exist.  I think people are conditioned by palloc
> > to expect such functions to throw error.
> 
> The only reason why I did not propose that for ShmemAlloc is because
> of extensions potentially using this routine and having some special
> handling when it returns NULL. And changing it to behave like palloc
> would break such extensions.

I suggest to keep ShmemAlloc as is for backward compatibility and
introduce a new procedure ShmemAllocSafe. Also we could add a scary
comment (and also a warning log message?) that ShmemAlloc is deprecated
and possibly will be removed in later releases.

-- 
Best regards,
Aleksander Alekseev


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (33+ messages)  latest in thread

Message-ID: <20160830133048.GA84635@e733>
Permalink:  ../20160830133048.GA84635@e733/
Also on:    postgresql.org/message-id/20160830133048.GA84635@e733

 · 

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-hackers@postgresql.org
  Cc: a.alekseev@postgrespro.ru, michael.paquier@gmail.com, tgl@sss.pgh.pa.us, hlinnaka@iki.fi
  Subject: Re: Missing checks when malloc returns NULL...
  In-Reply-To: <20160830133048.GA84635@e733>
  References: <7978.1466516782@sss.pgh.pa.us> <CAB7nPqRRR8mnM9kbGObV2tzP-BpmLotiKyVBPbY2bxjuAyeCpw@mail.gmail.com> <d4b09f6b-06b9-2678-a0f8-714e3468b9eb@iki.fi> <CAB7nPqQhEF854DuLPaqpx+FfrY3YEcqYTVa12YKXMk_ayCtqqQ@mail.gmail.com> <CAB7nPqSCxBWt7Q1dpFTekg-zDx_GZ-ELgEOfYJ47zrD8=v=yHg@mail.gmail.com> <20160829130513.GA8340@e733> <20160829141315.GB8340@e733> <CAB7nPqSaEQPSXusCEqT=dsB3rpSA=k7EQVxCu63y8N4URmV3CA@mail.gmail.com> <24843.1472563085@sss.pgh.pa.us> <CAB7nPqRDbjezFe_AeA8zYVqx20yZwW9n3Aj93KO5485D2G8BHA@mail.gmail.com> <20160830133048.GA84635@e733>

* 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