p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   simple arithmetic overflow vbscript (http://p2p.wrox.com/showthread.php?t=47532)

handy September 7th, 2006 10:21 PM

simple arithmetic overflow vbscript
 
Hi, I have a windows 2003 server running ASP. Initially everything was fine. But recently it throws 'overflow' error when executing basic arithmetic.

The error is:
Microsoft VBScript runtime error '800a0006'
Overflow

I created a simple asp:
<%@ Language=VBScript%>
<%
option explicit

dim a,b,c,d

a = 1
b = 1
c = 1

d = a * b / c
response.write d
%>
The overflow error is at line (d = a * b / c).

And the wierd thing is that it happens randomly. sometimes it's fine, sometimes it throws 'overflow' error. When i restart IIS service, it ALWAYS working fine in the beginnig. After few hours later, 'overflow' error begins to surface. w3wp.exe is around 100mb.

But when i run the same code (in .vbs) on the server, looping for 1000 times, it doesnt give me the 'overflow' error. Also i created the same codes using vb.net, it doesnt give me the 'overflow' error.

Is this some kind of a virus? In the end I reformated the server and everything works great for few months till recently the same 'overflow' error appears.

Please2 help.

dparsons September 8th, 2006 07:38 AM

are ABC always defined as displayed above, or are they variables? Can C ever be 0?

"The one language all programmers understand is profanity."

mat41 September 9th, 2006 10:21 PM

The 0 thing was one of my thoughts.

>What are the values of a, b and c at the time of overflow?
>Are you not using cInt or cLng functions? (use then see if your error chnages to 'invalid use of cInt')

Wind is your friend
Matt

handy September 10th, 2006 09:46 PM

Thanks for the reply.

a,b,c is set to 1 and never change in the code. The code is as above. Unless c can suddenly change to 0...... I will output abcd then, and see what happen.

I did try using cInt and cDbl, but it also returns 'overflow' error.

Currently the servers seems to be working as i configure IIS to recycle worker processors every 10 hours, and i created 3 worker processor instead of 1.

Could it be asp engine problem? how can i diagnose/troubleshoot it? any recommendations what tools to use? Thanks

mat41 September 10th, 2006 10:09 PM

;;;a,b,c is set to 1 and never change in the code
if it never changes why calculate? you lost me a bi there.

Which brigs me to:
;;;Unless c can suddenly change to 0
mmmmmm, now Im really confused. You cant out put a result if a division by 0 is present

;;; did try using cInt and cDbl,
I hav ehad your error before. My prblem was results that were outside the range of an allowed integer using cInt, cDble fixed it.

;;;how can i diagnose/troubleshoot it?
Strip you page back till error free, test n run, test n run, test n run - until you find your problem. mmmmm, a slow long winded process. It will tell you where your problem is sometime during this process. There is a heap of info on your error on the net, several causes, have you googled it?

BTW is is a stack overflow error or just an overfloe error? IME these are un common and are like a needle in the haystack. Sorry couldnt be much help...

Wind is your friend
Matt

handy September 10th, 2006 11:39 PM

Sorry for the confusion. The real codes is not like the above. The above is the simple test code to show that even 1*1/1 simple calculation can create strange 'overflow' error in 2 of my server 2003. The real code is to resize the image based on the inputed height or width.

Initially i thought it's because of cInt or cDble, so i convert everything (using cInt and cDble) in the codes, but it still gives me the 'overflow' error. After debugging the codes, i found out that it's definately not because of division of 0 or outside the range of datatype. Because with the same value of abc, sometimes got 'overflow' and sometimes are fine. So, I created the simple arithmetic page (which is 1*1/1), and it gives me 'overflow' error!???

The error:
Microsoft VBScript runtime error '800a0006'
Overflow

then the line that causes the error (which is on the 1*1/1)



Thanks.

handy September 11th, 2006 04:19 AM

the servers now is going wild!!! keep on giving overflow error. funny thing is that the 'overflow' error occured when im doing a division. but it's not division by 0.

my test page is as follow:
<%
on error resume next
dim a,b,c,d

a = 1
b = 1
c = 1
d = cdbl(cdbl(cdbl(a) * cdbl(b)) / cdbl(c))
response.write a & " * " & b & " / " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a + b + c
response.write a & " + " & b & " + " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a * b + c
response.write a & " * " & b & " + " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a + b / c
response.write a & " + " & b & " / " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a * b / c
response.write a & " * " & b & " / " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a / b * c
response.write a & " / " & b & " * " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 1
b = 1
c = 1
d = a + b - c
response.write a & " + " & b & " - " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 80
b = 144
c = 177
d = a * b / c
response.write a & " * " & b & " / " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 80
b = 144
c = 177
d = a + b / c
response.write a & " + " & b & " / " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 80
b = 144
c = 177
d = a + b * c
response.write a & " + " & b & " * " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear

a = 80
b = 144
c = 177
d = a + b + c
response.write a & " + " & b & " + " & c
response.write " = " & d
response.write err.description & "<br>"
err.clear
%>

The 'overflow' occurs on ALL the lines that has the division. Please note that this happens quite randomly.

mat41 September 11th, 2006 07:00 AM

Wish I could help. I have seen this only once, your issue isnt jumping out at me. I guess stripping it back doesnt tell you much if its only a random problem

Wind is your friend
Matt

dparsons September 11th, 2006 07:36 AM

This line here:

a = 80
b = 144
c = 177
d = a + b / c

What value are you expecting? Because I get 80.813559322033898305084745762712

"The one language all programmers understand is profanity."

handy September 13th, 2006 01:21 AM

thanks mat for bothering into looking at this.
dparsons, you are right,
a = 80
b = 144
c = 177
d = a + b / c
should return 80.813559322033898305084745762712

However, on my 2 servers, sometimes it returns the correct answer, and sometimes gives me 'overflow' error. The 'overflow' error occurs randomly. My point is no matter what value i put, the division arithmetic will gives me random 'overflow' error, even 1+1/1!!!!


All times are GMT -4. The time now is 07:17 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.