Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 7th, 2006, 10:21 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote
  #2 (permalink)  
Old September 8th, 2006, 07:38 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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

"The one language all programmers understand is profanity."
Reply With Quote
  #3 (permalink)  
Old September 9th, 2006, 10:21 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
  #4 (permalink)  
Old September 10th, 2006, 09:46 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #5 (permalink)  
Old September 10th, 2006, 10:09 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;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
Reply With Quote
  #6 (permalink)  
Old September 10th, 2006, 11:39 PM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #7 (permalink)  
Old September 11th, 2006, 04:19 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Reply With Quote
  #8 (permalink)  
Old September 11th, 2006, 07:00 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

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
Reply With Quote
  #9 (permalink)  
Old September 11th, 2006, 07:36 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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."
Reply With Quote
  #10 (permalink)  
Old September 13th, 2006, 01:21 AM
Registered User
 
Join Date: Sep 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!!!!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arithmetic overflow error gregalb Reporting Services 1 June 24th, 2008 02:42 PM
Odd arithmetic overflow error.... 7racer SQL Server 2000 4 May 12th, 2006 09:17 AM
arithmetic overflow problem flyfish SQL Server 2000 4 July 12th, 2005 04:37 PM
Arithmetic overflow error converting expression to sinapra Classic ASP Databases 8 September 3rd, 2004 12:24 AM
Arithmetic overflow error converting expression to spikey SQL Server 2000 1 June 24th, 2003 07:19 PM



All times are GMT -4. The time now is 03:47 AM.


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