pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael.paquier@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Provide overflow safe integer math inline functions.
Date: Thu, 14 Dec 2017 13:05:32 +0900
Message-ID: <CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@mail.gmail.com> (raw)
In-Reply-To: <20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de>
References: <E1eOvQF-00075r-Cy@gemulon.postgresql.org>
	<20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de>

On Thu, Dec 14, 2017 at 6:37 AM, Andres Freund <andres@anarazel.de> wrote:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=dangomushi&dt=2017-12-13%2018%3A00%3A18
>
> which seems half like a compiler bug to me. But either way, we gotta
> work around it.  I suspect the reason configure test doesn't
> sufficiently detect this here is because it's testing the function with
> constant arguments.

This uses clang 5.0 and I can reproduce the failure manually:
$ clang --version
clang version 5.0.0 (tags/RELEASE_500/final)
Target: armv7l-unknown-linux-gnueabihf
Thread model: posix
InstalledDir: /usr/bin

Note that on the same machine using gcc 7.2.0 I am seeing no
compilation failures. ArchLinux maintainers can be sometimes wild in
the versions they push, I have seen that in the past. And Arch ARM has
less resources I think.

Also, gull is complaining with the same failure:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=gull&dt=2017-12-13%2004%3A20%3A18
ARMv7 is used there as well, with clang 3.8, so this combination is deadly.

> Could you perhaps test whether replacing PGAC_C_BUILTIN_OP_OVERFLOW's body with something like
> result
> PG_INT64_TYPE a;
> PG_INT64_TYPE b;
> PG_INT64_TYPE result;
> __builtin_mul_overflow(*(volatile PG_INT64_TYPE*) &a, *(volatile PG_INT64_TYPE*) &b, &result);
>
> makes it fail? I'd rather not test this via the buildfarm, given that
> dangomushi isn't the most frequently running / fastest animal.

The tests are run once per day to not push too much its SD card.

Let me see... If I enforce also a cast on "result" as well then I am
able to compile correctly, which gives me the attached. make check
also works, I haven't taken the time to do a complete test run though,
this would take way longer on dangomushi.
-- 
Michael

Attachments:

builtin-multi-conf.patch (application/octet-stream, 1.1K) download diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index ed26644a48..a3dc7f9cac 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -310,8 +310,12 @@ fi])# PGAC_C_BUILTIN_CONSTANT_P AC_DEFUN([PGAC_C_BUILTIN_OP_OVERFLOW], [AC_CACHE_CHECK(for __builtin_mul_overflow, pgac_cv__builtin_op_overflow, [AC_LINK_IFELSE([AC_LANG_PROGRAM([], -[PG_INT64_TYPE result; -__builtin_mul_overflow((PG_INT64_TYPE) 1, (PG_INT64_TYPE) 2, &result);] +[PG_INT64_TYPE a; +PG_INT64_TYPE b; +PG_INT64_TYPE result; +__builtin_mul_overflow(*(volatile PG_INT64_TYPE*) &a, + *(volatile PG_INT64_TYPE*) &b, + *(volatile PG_INT64_TYPE*) &result);] )], [pgac_cv__builtin_op_overflow=yes], [pgac_cv__builtin_op_overflow=no])]) diff --git a/configure b/configure index ca76ef0ab2..b6d60c97dc 100755 --- a/configure +++ b/configure @@ -14485,8 +14485,12 @@ else int main () { +PG_INT64_TYPE a; +PG_INT64_TYPE b; PG_INT64_TYPE result; -__builtin_mul_overflow((PG_INT64_TYPE) 1, (PG_INT64_TYPE) 2, &result); +__builtin_mul_overflow(*(volatile PG_INT64_TYPE*) &a, + *(volatile PG_INT64_TYPE*) &b, + *(volatile PG_INT64_TYPE*) &result); ; return 0;

view thread (16+ messages)  latest in thread

Message-ID: <CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@mail.gmail.com>
Permalink:  ../CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@mail.gmail.com/
Also on:    postgresql.org/message-id/CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@mail.gmail.com

 ·  · 

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 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-committers@postgresql.org
  Cc: michael.paquier@gmail.com, andres@anarazel.de, pgsql-hackers@postgresql.org
  Subject: Re: pgsql: Provide overflow safe integer math inline functions.
  In-Reply-To: <CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@mail.gmail.com>
  References: <E1eOvQF-00075r-Cy@gemulon.postgresql.org> <20171213213754.pydkyjs6bt2hvsdb@alap3.anarazel.de> <CAB7nPqSQXZdHNEJCg4nm0EtAWOV3XPpruYwa7SLbsFUSoe_Pug@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox