| From: | Jeff Davis <pgsql(at)j-davis(dot)com> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | pgsql-bugs(at)postgresql(dot)org | 
| Subject: | Re: init_htab causes SIGFPE (or worse) due to miscalculation for large nbuckets | 
| Date: | 2012-12-11 02:05:49 | 
| Message-ID: | 1355191549.15663.10.camel@sussancws0025 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
On Mon, 2012-12-10 at 20:27 -0500, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > It looks like all of the callers, except two, immediately shift the
> > result. So perhaps it would be better to make a new function (something
> > like "ceil_pow2") that returns the lowest power of two greater than or
> > equal to the input, and it can return a long (bounded to +LONG_MAX).
> 
> That does seem like a good idea.  We need one for an int-sized result
> too, to fix the original problem in init_htab.  So I propose these
> functions:
Looks good to me. One other corner case in the version of the patch I
was working on was that nbuckets is compared to num_partitions, which is
a long. We can assert that it is less than or equal to INT_MAX in
hash_create.
Aside from that, I'll drop my version of the patch, which doesn't have
any useful differences from yours.
Regards,
	Jeff Davis
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2012-12-11 02:19:07 | Re: init_htab causes SIGFPE (or worse) due to miscalculation for large nbuckets | 
| Previous Message | Tom Lane | 2012-12-11 01:27:22 | Re: init_htab causes SIGFPE (or worse) due to miscalculation for large nbuckets |