| From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Magnus Hagander <mha(at)sollentuna(dot)net>, Wang Haiyong <wanghaiyong(at)neusoft(dot)com>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
| Subject: | Re: Fix for Win32 division involving INT_MIN |
| Date: | 2006-06-09 02:40:30 |
| Message-ID: | 200606090240.k592eUj23952@candle.pha.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs pgsql-patches |
Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > With no Win32 exception detection code in sight, I propose the following
> > patch to prevent server crashes for unusual INT_MIN integer division.
>
> The overflow code tries hard to avoid assuming it knows what INT_MIN and
> INT_MAX are --- this is maybe not so important for int4 but it is for
> int8 (because of our support for int8-less machines). I don't
> immediately see how to make this test without assuming you know the
> value of INT_MIN, but we ought to try to come up with one.
>
> We do see funny behavior on Intel chips even without Windows, so it'd
> be better to not #ifdef WIN32 but use the same overflow test for
> everyone.
> I would imagine the same problem arises with int8, has anyone checked?
Seems int8 is OK on Win32:
postgres=# SELECT (-9223372036854775808) / (-1);
ERROR: bigint out of range
> Also, the overflow tests in the intNmul routines seem vulnerable.
I reproduced the crash using int4 multiplication. Again int8
multiplication seemed OK.
I tried int2 and that seemed OK.
Updated patch attached.
--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
| Attachment | Content-Type | Size |
|---|---|---|
| /pgpatches/int_min | text/x-diff | 1.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | kah_hang_ang | 2006-06-09 09:29:08 | Re: statement stuck when the connection grew up to 45 or more |
| Previous Message | Tom Lane | 2006-06-09 02:18:04 | Re: Fix for Win32 division involving INT_MIN |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dhanaraj M | 2006-06-09 05:35:03 | Re: Patch for - Allow server logs to be remotely read |
| Previous Message | Tom Lane | 2006-06-09 02:18:04 | Re: Fix for Win32 division involving INT_MIN |