Re: pgsql: Fix pg_size_pretty() to avoid overflow for inputs close to INT64

From: Dave Page <dpage(at)postgresql(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-committers <pgsql-committers(at)postgresql(dot)org>
Subject: Re: pgsql: Fix pg_size_pretty() to avoid overflow for inputs close to INT64
Date: 2011-04-28 19:57:14
Message-ID: BANLkTik1Em8=mxVfw2db2VO6ejxbjf1NKA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Apr 28, 2011 at 8:44 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Dave Page <dpage(at)postgresql(dot)org> writes:
>> On Thu, Apr 28, 2011 at 6:21 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Dave, can you poke at this?
>
>> I think we may have to award Sun (or whats left of them) the "Bizarre
>> compiler bug of the week" award here.
>
> Yeah.  Has anyone filed a report with them?

I haven't. Oracle dont seem to make it easy to do such things (at
least for those of us without support contracts).

>> It's actually the val++; that's
>> causing the assertion, but I'm darned if I can get it to work. I've
>> tried spelling out the addition, casting, changing val to an int64*,
>> renaming val, and probably a dozen or so things that are broken, all
>> with no success.
>> Any other ideas?
>
> I was suspicious that it had something to do with the compiler trying to
> optimize the size / mult and size % mult subexpressions to get both
> results with one division instruction.  Can you check if removing either
> of those makes the crash go away?

Already did (that was my first assumption). Removing them doesn't
help, nor does rewriting them in various strange ways. Removing val++;
(and replacing with { } ) allows compilation to succeed.

I guess the best bet is a compiler update, if I can persuade the
oracle website to let me download it...

--
Dave Page
PostgreSQL Core Team
http://www.postgresql.org/

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2011-04-28 20:05:19 Re: pgsql: Fix pg_size_pretty() to avoid overflow for inputs close to INT64
Previous Message Tom Lane 2011-04-28 19:44:26 Re: pgsql: Fix pg_size_pretty() to avoid overflow for inputs close to INT64

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-04-28 20:01:59 Re: Extreme bloating of intarray GiST indexes
Previous Message Tom Lane 2011-04-28 19:44:26 Re: pgsql: Fix pg_size_pretty() to avoid overflow for inputs close to INT64