Re: Using 128-bit integers for sum, avg and statistics aggregates - Mailing list pgsql-hackers

From Petr Jelinek
Subject Re: Using 128-bit integers for sum, avg and statistics aggregates
Date
Msg-id 550F2D5D.9080700@2ndquadrant.com
Whole thread Raw
In response to Re: Using 128-bit integers for sum, avg and statistics aggregates  (Andreas Karlsson <andreas@proxel.se>)
Responses Re: Using 128-bit integers for sum, avg and statistics aggregates
List pgsql-hackers
On 22/03/15 13:59, Andreas Karlsson wrote:
> On 03/22/2015 11:47 AM, Petr Jelinek wrote:
>> On 22/03/15 10:35, Andres Freund wrote:
>>>> http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=jacana&dt=2015-03-21%2003%3A01%3A21
>>>>
>>>>
>>>
>>> That's the stuff looking like random memory that I talk about above...
>>>
>>
>> If you look at it closely, it's actually not random memory. At least in
>> the first 2 failing tests which are not obfuscated by aggregates on top
>> of aggregates. It looks like first NumericDigit is ok and the second one
>> is corrupted (there are only 2 NumericDigits in those numbers). Of
>> course the conversion to Numeric is done from the end so it looks like
>> only the last computation/pointer change/something stays ok while the
>> rest got corrupted.
>
> Would this mean the bug is most likely somewhere in
> int128_to_numericvar()? Maybe that version of gcc has a bug in some
> __int128 operator or I messed up the code there somehow.
>

Yeah that's what I was thinking also, and I went through the function 
and didn't find anything suspicious (besides it's same as the 64 bit 
version except for the int128 use).

It really might be some combination of arithmetic + the conversion to 
16bit uint bug in the compiler. Would be worth to try to produce test 
case and try it standalone maybe?

--  Petr Jelinek                  http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Zero-padding and zero-masking fixes for to_char(float)
Next
From: Florian Weimer
Date:
Subject: Re: Remove fsync ON/OFF as a visible option?