pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Don't be so trusting that shm_toc_lookup() will always succeed.
Date: Mon, 05 Jun 2017 16:05:48 +0000
Message-ID: <E1dHuVo-0001R3-4f@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Don't be so trusting that shm_toc_lookup() will always succeed.

Given the possibility of race conditions and so on, it seems entirely
unsafe to just assume that shm_toc_lookup() always finds the key it's
looking for --- but that was exactly what all but one call site were
doing.  To fix, add a "bool noError" argument, similarly to what we
have in many other functions, and throw an error on an unexpected
lookup failure.  Remove now-redundant Asserts that a rather random
subset of call sites had.

I doubt this will throw any light on buildfarm member lorikeet's
recent failures, because if an unnoticed lookup failure were involved,
you'd kind of expect a null-pointer-dereference crash rather than the
observed symptom.  But you never know ... and this is better coding
practice even if it never catches anything.

Discussion: https://postgr.es/m/9697.1496675981@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d4663350646ca0c069a36d906155a0f7e3372eb7

Modified Files
--------------
src/backend/access/transam/parallel.c     | 31 ++++++++++++-------------------
src/backend/executor/execParallel.c       | 16 ++++++++--------
src/backend/executor/nodeBitmapHeapscan.c |  2 +-
src/backend/executor/nodeCustom.c         |  2 +-
src/backend/executor/nodeForeignscan.c    |  2 +-
src/backend/executor/nodeIndexonlyscan.c  |  2 +-
src/backend/executor/nodeIndexscan.c      |  2 +-
src/backend/executor/nodeSeqscan.c        |  2 +-
src/backend/storage/ipc/shm_toc.c         | 10 +++++++++-
src/include/storage/shm_toc.h             |  2 +-
src/test/modules/test_shm_mq/worker.c     |  6 +++---
11 files changed, 39 insertions(+), 38 deletions(-)


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


Message-ID: <E1dHuVo-0001R3-4f@gemulon.postgresql.org>
Permalink:  ../E1dHuVo-0001R3-4f@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dHuVo-0001R3-4f@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Don't be so trusting that shm_toc_lookup() will always succeed.
  In-Reply-To: <E1dHuVo-0001R3-4f@gemulon.postgresql.org>
  References: <E1dHuVo-0001R3-4f@gemulon.postgresql.org>

* 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