public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Rowley <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: Masahiko Sawada <[email protected]>
Cc: [email protected]
Subject: Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p
Date: Fri, 21 Mar 2025 00:17:56 +1300
Message-ID: <CAApHDvrFdXjbrV6KCx_GHKYSufUbNDYSsjppcJQiGOURfJE6qg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CAApHDvqrhFfnetbcwgGkJ=z63T8HfQ_OyP=vX8BYiXyxFKt67w@mail.gmail.com>
<[email protected]>
<CAApHDvqf4tKwE0oP8ybL2Eu-SD=C34pdZ9vVDSJwvqDXi88nUg@mail.gmail.com>
<[email protected]>
On Thu, 13 Mar 2025 at 21:33, Peter Eisentraut <[email protected]> wrote:
> Ok, this is weird, because we have pg_unreachable() support for MSVC:
>
> #if defined(HAVE__BUILTIN_UNREACHABLE) && !defined(USE_ASSERT_CHECKING)
> #define pg_unreachable() __builtin_unreachable()
> #elif defined(_MSC_VER) && !defined(USE_ASSERT_CHECKING)
> #define pg_unreachable() __assume(0)
> #else
> #define pg_unreachable() abort()
> #endif
>
> Is there a way to reshuffle those conditionals to make this actually do
> something useful on MSVC?
I've just been experimenting with this and it seems the problem isn't
with pg_unreachable(), it's with the compiler not understanding that
the particular pg_unreachable() is always reached.
What's happening is down to the multi-eval protection code for elevel
in ereport_domain(). Because elevel is assigned to the variable
"elevel_" the compiler seems to lose its proof that the
pg_unreachable() is always reached. Adjusting that condition to use
the elevel parameter directly makes the warning disappear.
I looked around to see if MSVC might have something to allow us to fix
this, but didn't find anything. There does not seem to be any sort of
__builtin_constant_p with MSVC, otherwise we could've done something
similar to the HAVE__BUILTIN_CONSTANT_P version of ereport_domain just
above.
> Are you compiling with assertions on in this case? Does anything change
> about this if you don't use assertions (or vice versa)?
It happens with both.
David
view thread (16+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: pgsql: pg_logicalinspect: Fix possible crash when passing a directory p
In-Reply-To: <CAApHDvrFdXjbrV6KCx_GHKYSufUbNDYSsjppcJQiGOURfJE6qg@mail.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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox