Re: [GENERAL] division by zero - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: [GENERAL] division by zero
Date
Msg-id 303E00EBDD07B943924382E153890E5433F7EF@cuthbert.rcsinc.local
Whole thread Raw
List pgsql-hackers
Bruce Momjian wrote:
>
>
> The big question is how to fix this on Win32.  Is a test in the
integer
> division routines enough?

All divisions could be tested and the appropriate signal could get
raised by the handler.  I would hate to see what this would do to the
source.  In windows you can raise your own signals and we could probably
kludge it out that way.

> Is there a signal to catch on Win32?

There is not: in windows we use __try/__except in C and try/catch in
C++.  This is a vendor implementation but works in both borland and
microsoft compilers.  No idea elsewhere.

Here are the signals you do get: <quote>
SIGABRT

Abnormal termination. The default action terminates the calling program
with exit code 3.

SIGFPE

Floating-point error, such as overflow, division by zero, or invalid
operation. The default action terminates the calling program.

SIGILL

Illegal instruction. The default action terminates the calling program.

SIGINT

CTRL+C interrupt. The default action issues INT 23H.

SIGSEGV

Illegal storage access. The default action terminates the calling
program.

SIGTERM

Termination request sent to the program. The default action terminates
the calling program

</endquote>


Ideally, the exception could be caught and transferred to the
appropriate handler.  Its really hard to say how this would interact
with the postgres exception handler without a thorough investigation.

I would only perform a test following each divide as a last resort.

Merlin


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Backends created by ODBC live forever ...
Next
From: Justin Clift
Date:
Subject: Re: Who puts the Windows binaries on the FTP server?