Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p
Date: 2025-03-12 06:38:50
Message-ID: CAApHDvow4CPgEyHWuSpfMQN8vRYrMgMTOqsy2SwNbQruPVV0rw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Wed, 12 Mar 2025 at 18:18, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I don't know of an easy way. I experimented with doing this:
>
> diff --git a/src/include/c.h b/src/include/c.h
> index a14c6315162..467b1f58ae8 100644
> --- a/src/include/c.h
> +++ b/src/include/c.h
> @@ -315,7 +315,7 @@
> #elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
> #define pg_unreachable() __assume(0)
> #else
> -#define pg_unreachable() abort()
> +#define pg_unreachable() ((void) 0)
> #endif
>
> /*
>
> which seems like it ought to be enough to provoke such warnings
> (in assert-enabled builds). I got upwards of sixty build warnings
> this way, but the place David mentions was *not* among them.
> So I'm confused.

Doing that for me does show the new warning.

drowley(at)amd7945hx:~/pg_src$ meson setup -Dcassert=true build >
/dev/null && cd build && ninja | grep pg_logicalinspect.c
[1962/2356] Compiling C object
contrib/pg_logicalinspect/pg_logicalinspect.so.p/pg_logicalinspect.c.o
../contrib/pg_logicalinspect/pg_logicalinspect.c: In function
‘parse_snapshot_filename’:
../contrib/pg_logicalinspect/pg_logicalinspect.c:88:1: warning:
control reaches end of non-void function [-Wreturn-type]
drowley(at)amd7945hx:~/pg_src$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

David

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2025-03-12 07:58:53 pgsql: Prepare for Python "Limited API" in PL/Python
Previous Message Tom Lane 2025-03-12 05:18:09 Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p