pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix asserts in fast-path locking code
Date: Mon, 23 Sep 2024 09:44:04 +0000
Message-ID: <E1ssfbv-000WVf-M1@gemulon.postgresql.org> (raw)

Fix asserts in fast-path locking code

Commit c4d5cb71d229 introduced a couple asserts in the fast-path locking
code, upsetting Coverity.

The assert in InitProcGlobal() is clearly wrong, as it assigns instead
of checking the value. This is harmless, but doesn't check anything.

The asserts in FAST_PATH_ macros are written as if for signed values,
but the macros are only called for unsigned ones. That makes the check
for (val >= 0) useless. Checks written as ((uint32) x < max) work for
both signed and unsigned values. Negative values should wrap to values
greater than INT32_MAX.

Per Coverity, report by Tom Lane.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/2891628.1727019959@sss.pgh.pa.us

Branch
------
master

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

Modified Files
--------------
src/backend/storage/lmgr/lock.c | 8 ++++----
src/backend/storage/lmgr/proc.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)



Message-ID: <E1ssfbv-000WVf-M1@gemulon.postgresql.org>
Permalink:  ../E1ssfbv-000WVf-M1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ssfbv-000WVf-M1@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix asserts in fast-path locking code
  In-Reply-To: <E1ssfbv-000WVf-M1@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