473,467 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

BUG: Incorrect / inconsistent program behaviour when the "Remove Integer Overflow Checks" option is enabled

This is a worrying bug, and indicates a potential problem in the Framework
CLR. This bug affected a project I was working on, which behaved differently
when run from the Visual Studio IDE than when run by double clicking on the
project's EXE file. The problem can be replicated easily:

Create a new project in Visual Studio 2003 and add the following code.
Module Main
Sub Main()
Dim xmlDoc As New System.Xml.XmlDocument
xmlDoc.AppendChild(xmlDoc.CreateElement("Root"))
Dim o, n As Object
Dim count As Integer
For Each o In xmlDoc.ChildNodes
For n = 0 To 9
count += 1
Next
Next
System.Windows.Forms.MessageBox.Show("Count: " & count)
End Sub
End Module
IMPORTANT: To replicate the bug, you must

(1) Set the project compile mode to "Release"
(2) Enable the following option: Project Configuration Properties /
Optimisations / "Remove Integer Overflow Checks"

Finally, run the program from the Visual Studio IDE. The expected message,
"Count: 10", is displayed. Now run the program from it's EXE file via
Windows Explorer. A message, "Count: 1" is displayed, which is incorrect.
Nov 20 '05 #1
3 1354
Ralph,

Interesting, that does indeed look like some kind of JIT compiler bug.

FYI, changing the loop variable n to an Integer fixes the problem. Why
did you have it declared as Object anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #2
I know it fixes it, but I wanted to show the problem. Actually, changing the
code in almost any way fixes the problem.

It's a rather worrying thought that this kind arbitrary JIT compiler problem
might affect anyone's code.

So, there was no specific reason for the Object declaration, other than the
fact that I wanted to provide a simple example that did not break the
problem. (In my shipping code I used a For / Each for the inner loop, not an
object).
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
Ralph,

Interesting, that does indeed look like some kind of JIT compiler bug.

FYI, changing the loop variable n to an Integer fixes the problem. Why
did you have it declared as Object anyway?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 20 '05 #3
Ralph,
I know it fixes it, but I wanted to show the problem. Actually, changing the
code in almost any way fixes the problem.
OK, fine. FWIW, the bug seems to be fixed in Whidbey.

It's a rather worrying thought that this kind arbitrary JIT compiler problem
might affect anyone's code.


Well, there will always be bugs.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: aj | last post by:
DB2 v8 FP5 Red Hat AS/EL 2.1 I found the following in my db2diag.log: 2004-09-07-10.01.37.747898 Instance:oltp Node:000 PID:14637(db2agent (NDRDB)) TID:8192 ...
1
by: BillCo | last post by:
I've been running a text-to-table import as part of a daily routine for years and I've just added a few new fields and updated the import spec. The strange thing is that it works perfectly when...
3
by: poifull | last post by:
Hi All, What is the proper way to read a binary file into a byte? I am using BinaryReader to read from a Stream and call the ReadByte method of the BinaryReader object. The method I'm using...
2
by: SAL | last post by:
I have the following line of code in my Page_Load Event of my ASP.net page: txtExplanationofChange.Attributes.Add ("style","overflow :hidden"); which allows me to can turn off the Scrollbar of my...
2
by: ppuniversal | last post by:
hello, my program snippet: /*****************************/ /******runThread Function*****/ /*to accept other client connections*/ /*****************************/ DWORD WINAPI...
20
by: chutsu | last post by:
I'm trying to compare between pointer and integer in an "IF" statement how do I make this work? if(patient.id != NULL){ } Thanks Chris
3
by: _Christopher\(M2M\) | last post by:
Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600) How do I get rid of "Warning C4307: '-' : integral constant overflow" from the following macro? #define...
0
by: snowdream1982 | last post by:
Dear all, I hit an error OVERFLOW but when I insert the sql statement below manually in the SQLEditor, it goes well, no errors at all. My coding: SQLInsertTempMf = "INSERT INTO tempmf " &...
1
by: rileyjane | last post by:
Hello, I am running a Union query in Access 2003 that combines two other queries. When I run each query individually, they open fine with no problems. But when I try to run the Union query, I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.