Advertisement

Integer Division by Zero...... emmm What the ...??

Started by December 07, 2008 01:36 PM
3 comments, last by Matias Goldberg 15 years, 11 months ago
Hi all! You can skip the first parragraph if you don't want to read the introduction I was testing my game in an old machine, to see how well it performed on low end machines. After a couple of DirectX crashes (the old machine has a GeForce 4 MX! if you sure assume the GPU has shaders it will most likely crash!) I was able to smoothly (low quality settings of course :) ) run my game. However it suddenly crashed after some time. And such thing didn't happen in my newest PC. So I guessed it would be another GPU bug. But the my logs weren't saying anything weird. Being as stubborn as I am, I run it thoroughly with a remote debugger, to find out it was an INTEGER DIVISION BY ZERO EXCEPTION! The video card had nothing to do with that. So I went back to my newest system and told the Debugger I wanted to catch Integer Division by Zero Exceptions. And voilá! I found the (nasty) bug (for the curious one, it was that at some point, my code path lead to something like "myVal = Another % 0" But I have the big question to ask: Why on earth the game continued normally (the glitch was obscure and nasty, but it wasn't related to app's functionallity) after the exception in my newest PC, but in the old one the same exception crashed the game??? Because both processors were aware knew it was an exception. Do some CPUs halt on an integer division by zero exception while others just skip it, like if nothing had happened? Is this an OS setting? a CPU bug/setting? I wasn't catching the exception at all. The point of this thread is the inconsistency of the application among CPUs. I was lucky actually to find the bug if it weren't because of that exception. New PC: Athlon64X2 5000+ (Brisbane) ASUS M2N-MX SE Old PC: Sempron 2200+ (Thoroughbred) ASRock K7S41GX Thanks in advice! Cheers Dark Sylinc PS: I was undecided to put this in the General Discussion forum or here.
Quote: Original post by Matias Goldberg
Do some CPUs halt on an integer division by zero exception while others just skip it, like if nothing had happened?
Is this an OS setting? a CPU bug/setting?
This doesn't answer your question, but it is interesting to note that PowerPC processors don't have a divide by zero exception at all, so divide-by-zero merely results in zero.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Advertisement
Quote: Original post by swiftcoder
Quote: Original post by Matias Goldberg
Do some CPUs halt on an integer division by zero exception while others just skip it, like if nothing had happened?
Is this an OS setting? a CPU bug/setting?
This doesn't answer your question, but it is interesting to note that PowerPC processors don't have a divide by zero exception at all, so divide-by-zero merely results in zero.

Well thanks, yeah others architectures behave differently. The PPC seems to behave like the PS2' processor which does the same thing.

However, two CPUs from the same architecture AND manufacturer are behaving differently. That doesn't seem quite right...

Congrats for reaching the 1500 score swift
Dark Sylinc
I can only speculate, here's my shot:
The FPU has a register which controls which exceptions are raised and which are not. By default, it's set that no exceptions are raised for FP operations.

So, maybe the new computer ran the division through floating point unit, no exception was raised and the NAN result didn't break anything.

Again, that's just speculation. You'd have to look at the assembler code and/or check the cpu manuals to know for sure.

Quote: Original post by Rattenhirn
I can only speculate, here's my shot:
The FPU has a register which controls which exceptions are raised and which are not. By default, it's set that no exceptions are raised for FP operations.

So, maybe the new computer ran the division through floating point unit, no exception was raised and the NAN result didn't break anything.

Again, that's just speculation. You'd have to look at the assembler code and/or check the cpu manuals to know for sure.

I said integer, not floating point. It was an idiv instruction.
AFAIK it should always crash.

Thanks for the reply anyway

This topic is closed to new replies.

Advertisement