Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / November 2005

Tip: Looking for answers? Try searching our database.

Major JIT Optimizer BUG

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boaz Sedan - 14 Nov 2005 16:01 GMT
Try running the following code (tested on .Net1.1 SP1) in both debug and
release builds. Notice the different results:

In the release build, Method B (which modifies an instance field) is never
called!!!

------------------------------------------------------
using System;

namespace MajorBUG
{
 class Class1
 {
   static void Main(string[] args)
   {
     A a = new A();
     Console.WriteLine(a.data);
     a.C("XYZ");
     Console.WriteLine(a.data);
   }
 }

 class A
 {
   public string data = "ABC";

   public void C(string value)
   {
     if (B(value))
       return;
   }

   public bool B(string value)
   {
     data = value;
       return true;
   }
 }
}
Mattias Sjögren - 14 Nov 2005 18:42 GMT
>Try running the following code (tested on .Net1.1 SP1) in both debug and
>release builds. Notice the different results:

I can't repro it, here it prints the expected result in both builds.

Mattias

Signature

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

Jon Skeet [C# MVP] - 14 Nov 2005 22:19 GMT
> >Try running the following code (tested on .Net1.1 SP1) in both debug and
> >release builds. Notice the different results:
>
> I can't repro it, here it prints the expected result in both builds.

Have you tried compiling it from the command line? Here are my results:

c:\test>csc /debug+ Test.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

c:\test>test
ABC
XYZ

c:\test>csc /debug- /o+ Test.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

c:\test>test
ABC
ABC

It seems to be okay with .NET 2.0 though.
I must say, I'm very surprised by this - I haven't seen anything
similar before.

I'll raise this with MS personally...

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mattias Sjögren - 15 Nov 2005 17:39 GMT
>Have you tried compiling it from the command line?

Yup that's what I did, but I may have forgotten /o or ran the wrong
executable or some other stupid mistake. My bad.

Mattias

Signature

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

Metallikanz! - 27 Nov 2005 07:06 GMT
The problem is not reproducible from VS (2003, 1.1 SP1) even in the retail build with the optimization thingie on.

But when we use csc it sure does come, the inconsistency baffles me!!

Metallikanz!

Mattias Sjögren <mattias.dont.want.spam@mvps.org> wrote:
> >Try running the following code (tested on .Net1.1 SP1) in both debug and
> >release builds. Notice the different results:
>
> I can't repro it, here it prints the expected result in both builds.

Have you tried compiling it from the command line? Here are my results:

c:\test>csc /debug+ Test.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

c:\test>test
ABC
XYZ

c:\test>csc /debug- /o+ Test.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

c:\test>test
ABC
ABC

It seems to be okay with .NET 2.0 though.
I must say, I'm very surprised by this - I haven't seen anything
similar before.

I'll raise this with MS personally...

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mattias Sjögren - 28 Nov 2005 22:37 GMT
>The problem is not reproducible from VS (2003, 1.1 SP1) even in the retail build with the optimization thingie on.

If you launch from VS make sure you use "Start without debugging".
Otherwise the app will start with the debugger attached which changes
the JIT behavior.

Mattias

Signature

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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.