From: Tristan Partin <tristan@neon.tech>
To: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers@postgresql.org
Subject: Re: Fix last unitialized memory warning
Date: Tue, 08 Aug 2023 10:14:57 -0500
Message-ID: <CUN9FLTQAMIQ.RANXYVABYETV@gonk> (raw)
In-Reply-To: <c1d63155-7ac7-90dc-2e82-12b97e497026@eisentraut.org>
References: <CT6HJ3U8068R.3A8SJMV02D9BC@gonk>
<8f7880cc-3622-1c0a-a126-5b47aafeee51@eisentraut.org>
<CTUJMJ1B57SL.3T8TKNTE9XSVD@gonk>
<fe3d9d88-9702-3339-d86a-98a121244c9c@eisentraut.org>
<CTV4SEUNM92R.2OM4SN8LB7CQN@gonk>
<54989bdd-d6fe-92dc-a7e3-f4f31252b7eb@eisentraut.org>
<CU6BH3JA3GCY.25ETDNK3LVULF@gonk>
<c1d63155-7ac7-90dc-2e82-12b97e497026@eisentraut.org>
On Tue Aug 8, 2023 at 5:20 AM CDT, Peter Eisentraut wrote:
> On 19.07.23 19:15, Tristan Partin wrote:
> > On Sun Jul 9, 2023 at 2:23 AM CDT, Peter Eisentraut wrote:
> >> On 06.07.23 15:41, Tristan Partin wrote:
> >> > On Thu Jul 6, 2023 at 3:21 AM CDT, Peter Eisentraut wrote:
> >> >> On 05.07.23 23:06, Tristan Partin wrote:
> >> >>> Thanks for following up. My system is Fedora 38. I can confirm
> >> this is
> >> >>> still happening on master.
> >> >>>
> >> >>> $ gcc --version
> >> >>> gcc (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4)
> >> >>> Copyright (C) 2023 Free Software Foundation, Inc.
> >> >>> This is free software; see the source for copying conditions.
> >> There is NO
> >> >>> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> >> PURPOSE.
> >> >>> $ meson setup build --buildtype=release
> >> >>
> >> >> This buildtype turns on -O3 warnings. We have usually opted against
> >> >> chasing warnings in -O3 level because there are often some
> >> >> false-positive uninitialized variable warnings with every new
> >> compiler.
> >> >>
> >> >> Note that we have set the default build type to debugoptimized, for
> >> that
> >> >> reason.
> >> > > Good to know, thanks.
> >> > > Regarding the original patch, do you think it is good to be applied?
> >>
> >> That patch looks reasonable. But I can't actually reproduce the
> >> warning, even with gcc-13. I do get the warning from plpgsql. Can
> >> you show the warning you are seeing?
> >
> > Here is the full warning that the original patch suppresses.
>
> I was able to reproduce the warning now on Fedora. I agree with the patch
>
> - PgBenchValue vargs[MAX_FARGS];
> + PgBenchValue vargs[MAX_FARGS] = { 0 };
>
> I suggest to also do
>
> typedef enum
> {
> - PGBT_NO_VALUE,
> + PGBT_NO_VALUE = 0,
>
> to make clear that the initialization value is meant to be invalid.
>
> I also got the plpgsql warning that you showed earlier, but I couldn't
> think of a reasonable way to fix that.
Applied in v2.
--
Tristan Partin
Neon (https://neon.tech)
Attachments:v2-0001-Fix-last-remaining-uninitialized-memory-warnings.patch (text/x-patch, 1.2K) download
From 7e28d060871b19a8c09539e2da5e226b780431b9 Mon Sep 17 00:00:00 2001
From: Tristan Partin <tristan@neon.tech>
Date: Wed, 7 Jun 2023 09:21:59 -0500
Subject: [PATCH v2] Fix last remaining uninitialized memory warnings
gcc fails to properly analyze the code due to the loop stop condition
including `l != NULL`. Let's just help it out.
---
src/bin/pgbench/pgbench.c | 2 +-
src/bin/pgbench/pgbench.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 539c2795e2..2ba3e367c4 100644--- a/src/bin/pgbench/pgbench.c+++ b/src/bin/pgbench/pgbench.c@@ -2239,7 +2239,7 @@ evalStandardFunc(CState *st,
{
/* evaluate all function arguments */
int nargs = 0;
- PgBenchValue vargs[MAX_FARGS];+ PgBenchValue vargs[MAX_FARGS] = { 0 };
PgBenchExprLink *l = args;
bool has_null = false;
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.hindex 957c9ca9da..f8efa4b868 100644--- a/src/bin/pgbench/pgbench.h+++ b/src/bin/pgbench/pgbench.h@@ -33,7 +33,7 @@ union YYSTYPE;
*/
typedef enum
{
- PGBT_NO_VALUE,+ PGBT_NO_VALUE = 0,
PGBT_NULL,
PGBT_INT,
PGBT_DOUBLE,
--
Tristan Partin
Neon (https://neon.tech)
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-hackers@postgresql.org
Cc: tristan@neon.tech, peter@eisentraut.org
Subject: Re: Fix last unitialized memory warning
In-Reply-To: <CUN9FLTQAMIQ.RANXYVABYETV@gonk>
* 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