Re: pgsql: Provide overflow safe integer math inline functions.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Subject: Re: pgsql: Provide overflow safe integer math inline functions.
Date: 2017-12-17 00:32:07
Message-ID: 20171217003207.3myeahkbsm63kbvl@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2017-12-13 13:37:54 -0800, Andres Freund wrote:
> Hi Michael,
>
> On 2017-12-13 01:01:19 +0000, Andres Freund wrote:
> > Provide overflow safe integer math inline functions.
>
> 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.
>
> 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.

I've since tried this via the buildfarm, but still:

configure:14480: checking for __builtin_mul_overflow
configure:14500: ccache clang -o conftest -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -g -O2 -D_GNU_SOURCE -I/usr/include/et conftest.c -lssl -lcrypto -lz -lreadline -lrt -lcrypt -ldl -lm >&5
configure:14500: $? = 0
configure:14508: result: yes

I'm not quite following. Could you check if the same happens without
-O2? Not because that'd be a solution, but to narrow down how this
happens?

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-12-17 01:31:01 Re: pgsql: Provide overflow safe integer math inline functions.
Previous Message Andres Freund 2017-12-16 20:57:00 pgsql: Try to detect runtime unavailability of __builtin_mul_overflow(i

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-12-17 01:31:01 Re: pgsql: Provide overflow safe integer math inline functions.
Previous Message Andreas Seltenreich 2017-12-16 23:26:45 Re: [sqlsmith] Parallel worker executor crash on master