From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag
Date: Mon, 9 Dec 2019 14:03:43 +0500
Message-ID: <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru> (raw)
In-Reply-To: <20191209080316.GA72921@paquier.xyz>
References: <a7e28b83-27b1-4e1c-c76b-4268c4b785bc@postgrespro.ru>
<20191209080316.GA72921@paquier.xyz>
09.12.2019 13:03, Michael Paquier пишет:
> On Mon, Dec 09, 2019 at 08:49:26AM +0500, Andrey Lepikhov wrote:
>> xact.c: In function ‘RecordTransactionAbort’:
>> xact.c:5709:55: warning: argument 1 null where non-null expected [-Wnonnull]
>> XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid)
>> + 1);
>
> Assert(twophase_gid != NULL);
> -
> - if (XLogLogicalInfoActive())
> - xl_xinfo.xinfo |= XACT_XINFO_HAS_GID;
>
> xlinfo is set in the first part logging the transaction commit and the
> record data is registered in the second, so I think that the original
> coding makes more sense than what you are suggesting. Perhaps it
> would help to just add an assertion on twophase_gid to make sure that
> it is not NULL in the part registering the data? After that we really
> have no bugs here, so it does not really help much..
We already have assertion on the twophase_gid variable. But compiler is
not so smart and can't find a link between the XACT_XINFO_HAS_GID flag
and state of twophase_gid pointer.
>
>> formatting.c: In function ‘parse_datetime’:
>> formatting.c:4229:13: warning: ‘flags’ may be used uninitialized in this
>> function [-Wmaybe-uninitialized]
>> if (flags & DCH_ZONED)
>
> - uint32 flags;
> + uint32 flags = 0;
>
> do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error);
>
> For this one, OK. Wouldn't it be better to initialize flags, fprec
> and have_error directly in do_to_timestamp if they are not NULL? This
> way future callers of the routine, if any, won't miss the
> initialization.
Ok. In accordance with your review, I have prepared a new version of the
patch.
>
> By the way, are you using more specific CFLAGS to see that? With -O3
> and -Wnonnull I cannot spot both issues with GCC 9.2.1.
My compilation procedure:
export CFLAGS="-O3"
./configure --prefix=`pwd`/tmp_install --enable-tap-tests
--enable-depend && make clean
make > /dev/null
make install > /dev/null
My compiler:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.4.0-1ubuntu1~18.04.1'
--with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr --with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib
--enable-objc-gc=auto --enable-multiarch --disable-werror
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
--
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company
Attachments:
v2-0001-Make-compiler-quiet.patch (text/x-patch, 0B) download
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: a.lepikhov@postgrespro.ru, michael@paquier.xyz
Subject: Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag
In-Reply-To: <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru>
References: <a7e28b83-27b1-4e1c-c76b-4268c4b785bc@postgrespro.ru> <20191209080316.GA72921@paquier.xyz> <287cdd37-4021-da81-0378-cd367a279577@postgrespro.ru>
* 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