Re: Out of Memory - 8.2.4 - Mailing list pgsql-general

From Tom Lane
Subject Re: Out of Memory - 8.2.4
Date
Msg-id 3726.1188497277@sss.pgh.pa.us
Whole thread Raw
In response to Re: Out of Memory - 8.2.4  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Out of Memory - 8.2.4  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-general
Alvaro Herrera <alvherre@commandprompt.com> writes:
> !         /* no need to allocate more space than we have pages */
> !         maxtuples = LAZY_ALLOC_TUPLES * relblocks;

Uh ... you need to guard against integer overflow in this calculation.
Perhaps leave the current initialization alone, and then after the
Min-reduction steps add

        /* curious coding to ensure the multiplication can't overflow */
    if ((BlockNumber) (maxtuples / LAZY_ALLOC_TUPLES) > relblocks)
        maxtuples = relblocks * LAZY_ALLOC_TUPLES;

which is demonstrably overflow-proof once maxtuples has been clamped to
less than INT_MAX.

            regards, tom lane

pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Reliable and fast money transaction design
Next
From: Gregory Stark
Date:
Subject: Re: Out of Memory - 8.2.4