Re: Bug in window xp

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Wang Haiyong" <wanghaiyong(at)neusoft(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Bug in window xp
Date: 2006-04-08 10:40:35
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCEA0F8EC@algol.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

> "Magnus Hagander" <mha(at)sollentuna(dot)net> writes:
> > What we get is Integer Overflow, on the instruction "idiv
> esi" in postgres!int4div+0x1f. (Per windows debugger.) Same
> does not happen on Linux.
>
> > Tom - hints? ;-) Any idea why this happens on win32 but not linux?
>
> Perhaps there's some process-wide setting that enables or
> disables that?
>
> It seems fairly inconsistent to have a machine trap on divide
> overflow when it doesn't on any other integer overflow, so
> I'd rather turn it off than work around it.

Been doing some more research on this one. Seems that since this is a
hardware exception, there is no way to ignore it :-( What you can do is
create a structured exception filter that will get called, and can
detect it. At this point, you can "do your magic" and then have the
processor re-execute the instruction that failed - with any registers
modified per your preference.

So what we'd do in this case is, from what I can tell, to manipulate EIP
to make it point past the exception itself and then return
EXCEPTION_CONTINUE_EXECUTION.

However, this seems like a lot more of a kludge than putting in a check
in the code. And we'd need to know it's *always* safe to advance EIP
once on integer overflows, which I certainly can't speak for :-)

(If we just say continue execution, the program gets stuck in an
infinite loop because the exception just happens over and over again -
no surprise there)

So given that, I think I'm for putting in the check in the code.

As a sidenote, I noticed I never followed through on an old discussion
about crashing. Right now, when a postgres backend crashes it pops up a
GUI window to let the user know so. Only when the user has dismissed
this window does the postmaster notice. Attached patch changes this so
we don't provide GUI notification on crash, but instead just crashes and
let the postmaster deal with it.

//Magnus

Attachment Content-Type Size
gpf_box.patch application/octet-stream 614 bytes

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Oswaldo Hernández 2006-04-08 11:10:18 Re: Problema Order By en PosgreSQL 8.1
Previous Message Paolo Lopez 2006-04-08 05:42:39 Re: Problema Order By en PosgreSQL 8.1

Browse pgsql-patches by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-04-08 13:14:49 Re: bug in windows xp
Previous Message Tom Lane 2006-04-08 06:49:49 Re: Support Parallel Query Execution in Executor