Re: Fix last unitialized memory warning

From: "Tristan Partin" <tristan(at)neon(dot)tech>
To: "Peter Eisentraut" <peter(at)eisentraut(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix last unitialized memory warning
Date: 2023-08-08 15:14:57
Message-ID: CUN9FLTQAMIQ.RANXYVABYETV@gonk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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)

Attachment Content-Type Size
v2-0001-Fix-last-remaining-uninitialized-memory-warnings.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2023-08-08 15:25:52 Re: Cirrus-ci is lowering free CI cycles - what to do with cfbot, etc?
Previous Message Andres Freund 2023-08-08 15:13:45 Re: Cirrus-ci is lowering free CI cycles - what to do with cfbot, etc?