Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: >> 1. There are only about half a dozen places for a user-triggered >> division by zero to occur (the div and mod functions for int2, int4, >> int8; have I missed anything?). It would not be very painful to insert > It's unlikely to come up in practice,

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Stephan Szabo
On Mon, 10 Mar 2003, Tom Lane wrote: > "Merlin Moncure" <[EMAIL PROTECTED]> writes: > > The only other solution is a #ifdef win32 around places that potentially > > use integers in the divisor and do some nasty hacking. > > Well, it seems to me that we have two different issues to worry about: > >

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Doug Royer
Merlin Moncure wrote: Doug Royer wrote: No, try/catch does not trap division by zero unless the underlying implementation throws an error there is nothing to catch. I am absolutely 100% sure that you can catch int/0 with a try catch handler (in c++) on windows platforms (when compiled with ms/bo

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Merlin Moncure
Doug Royer wrote: > No, try/catch does not trap division by zero unless the underlying > implementation throws an error there is nothing to catch. > I am absolutely 100% sure that you can catch int/0 with a try catch handler (in c++) on windows platforms (when compiled with ms/borland compiler).

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Doug Royer
Merlin Moncure wrote: __try and __except, as far as I can tell are the only way to gracefully handle certain events. There is also a __finally. This is very much a Microsoft hack to C and not C++. GetExceptionCode() is from the win32 api. In C++, you get to use the much more standard try/cat

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > The only other solution is a #ifdef win32 around places that potentially > use integers in the divisor and do some nasty hacking. Well, it seems to me that we have two different issues to worry about: 1. There are only about half a dozen places for

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Merlin Moncure
Tom Lane wrote: > This is not C. I can't argue that; but it will compile on a C compiler on the Microsoft platform. I'm not sure if you were answering tongue-in-cheek, so for the benefit of the group: __try and __except, as far as I can tell are the only way to gracefully handle certain events.

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Tom Lane
"Merlin Moncure" <[EMAIL PROTECTED]> writes: > After fighting with the docs a little bit, here is how to handle an > int/0 in a C application. > __try > { > puts("in try"); > a = 0/b; > } > __except( HandleException(GetExceptionCode()) ) >

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Merlin Moncure
> The big question is how to fix this on Win32. Is a test in the integer > division routines enough? Is there a signal to catch on Win32? After fighting with the docs a little bit, here is how to handle an int/0 in a C application. #include "stdio.h" #include "excpt.h" #include "windows.h" i

Re: [HACKERS] [GENERAL] division by zero

2003-03-10 Thread Justin Clift
Bruce Momjian wrote: FWIW, this also is a problem with some of the windows ports. For example, 'select 0/0' is unpredictable and can cause the server to gpf and restart. This does not include the SRA port, because I don't have it. I just tested the SRA Win32 threaded port and both SELECT 1/0 and

Re: [HACKERS] [GENERAL] division by zero

2003-03-09 Thread Justin Clift
Hi guys, Was just looking around Google for similar reports of errors and came across this: MacOS X Server Developer Release Notes: Core OS Runtime http://www.geminisolutions.com/WebObjects_4.5/Documentation/Developer/YellowBox/ReleaseNotes/Runtime.html Looks like this is a known problem (as of

Re: [HACKERS] [GENERAL] division by zero

2003-03-09 Thread Eric B . Ridge
On Saturday, March 8, 2003, at 11:54 PM, Justin Clift wrote: Tom Lane wrote: 2. Consider this Apple's problem and file a bug report. Is there a good place to report errors to Apple for this kind of thing? The best place I can find is: http://developer.apple.com/bugreporter/index.html Unfortun

Re: [HACKERS] [GENERAL] division by zero

2003-03-08 Thread Merlin Moncure
Tom Lane wrote: > > I checked into this, and indeed OS X 10.2 is behaving funny: integer > divide by zero doesn't raise any signal, it just returns a bogus answer. > They're within their rights to do so according to the ANSI C spec > (wherein division by zero is stated to have undefined behavior).

Re: [HACKERS] [GENERAL] division by zero

2003-03-08 Thread Tom Lane
"Eric B. Ridge" <[EMAIL PROTECTED]> writes: > select 1/0; fails as expected on my x86 Linux box, so yer right, it's > just my little Mac. "I switched because Mac's can divide by zero." I checked into this, and indeed OS X 10.2 is behaving funny: integer divide by zero doesn't raise any signal,