Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: On a computer that is running the .NET Framework 3.5 Service Pack 1, the JIT compiler and the Native Image Generator (Ngen.exe) that use the Mscorjit.dll file may generate incorrect code


View products that this article applies to.

Symptoms

On a computer that is running the Microsoft .NET Framework 3.5 Service Pack 1 (SP1), the just-in-time (JIT) compiler and the Native Image Generator (Ngen.exe) that use the Mscorjit.dll file may generate incorrect code. Therefore, a 32-bit Managed C++ application may produce incorrect results.

This problem occurs if the following conditions are true:
  • The struct or the class in the source code has less than four scalar varieties and no managed object references.
  • You use the Cpblk instruction or the Initblk instruction.
Note This problem does not occur in a 64-bit application.

↑ Back to the top


Cause

This problem occurs because of a regression in the .NET Framework 3.5 SP1.

↑ Back to the top


Resolution

Hotfix information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

To download this hotfix from the MSDN Code Gallery, visit the following Microsoft Web site:


Note The MSDN Code Gallery displays the languages for which the hotfix is available. If you do not see your language listed, it is because the Code Gallery resource page is not available for that language.


Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:

Note If you have a 32-bit application that runs on a 64-bit platform, apply the hotfix for the 64-bit version to resolve this problem.

Prerequisites

You must have the .NET Framework 3.5 SP1 installed to apply this hotfix.

Restart requirement

You may have to restart the computer if any of the files that are updated are being used.

Hotfix replacement information

This hotfix does not replace any other hotfixes.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
Windows 2000, Windows XP, and Windows Server 2003, x86 versions
File nameFile versionFile sizeDateTime
Mscordacwks.dll2.0.50727.3068992,26416-Sep-200813:13
Mscorjit.dll2.0.50727.3068367,10416-Sep-200813:13
Mscorlib.dll2.0.50727.30684,546,56016-Sep-200813:13
Mscorwks.dll2.0.50727.30685,815,80816-Sep-200813:13
Windows 2000, Windows XP, and Windows Server 2003, x64 versions
File nameFile versionFile sizeDateTimePlatform
Mscordacwks.dll2.0.50727.3068992,26416-Sep-200813:13x86
Mscorjit.dll2.0.50727.3068367,10416-Sep-200813:13x86
Mscorlib.dll2.0.50727.30684,546,56016-Sep-200813:13x86
Mscorwks.dll2.0.50727.30685,815,80816-Sep-200813:13x86
Mscordacwks.dll2.0.50727.30681,767,94416-Sep-200810:33x64
Mscorjit.dll2.0.50727.30681,580,03216-Sep-200810:33x64
Mscorlib.dll2.0.50727.30684,562,94416-Sep-200810:33x64
Mscorwks.dll2.0.50727.306810,079,74416-Sep-200810:33x64
Windows 2000, Windows XP, and Windows Server 2003, IA-64 versions
File nameFile versionFile sizeDateTimePlatform
Mscordacwks.dll2.0.50727.3068992,26416-Sep-200813:13x86
Mscorjit.dll2.0.50727.3068367,10416-Sep-200813:13x86
Mscorlib.dll2.0.50727.30684,546,56016-Sep-200813:13x86
Mscorwks.dll2.0.50727.30685,815,80816-Sep-200813:13x86
Mscordacwks.dll2.0.50727.30683,087,88016-Sep-200810:44IA-64
Mscorjit.dll2.0.50727.30682,560,51216-Sep-200810:44IA-64
Mscorlib.dll2.0.50727.30684,005,88816-Sep-200810:44IA-64
Mscorwks.dll2.0.50727.306820,153,85616-Sep-200810:44IA-64
Windows Vista Service Pack 1 (SP1) and Windows Server 2008, x86 versions
File nameFile versionFile sizeDateTimePlatform
Mscorlib.resources.dll2.0.50727.3053352,25615-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053303,10415-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053315,39227-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053425,98415-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053307,20027-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053311,29627-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053331,77615-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053315,39215-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053307,20027-Jul-200817:55x86
Mscorlib.resources.dll2.0.50727.3053348,16027-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053319,48827-Jul-200817:55x86
Mscorlib.resources.dll2.0.50727.3053290,81615-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053303,10415-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053311,29615-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053303,10427-Jul-200817:55x86
Mscorlib.resources.dll2.0.50727.3053307,20015-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.1434397,31211-Jan-200822:59x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:55x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:55x86
Big5.nlpNot Applicable66,72818-Dec-200721:03Not Applicable
Bopomofo.nlpNot Applicable82,17218-Dec-200721:03Not Applicable
Ksc.nlpNot Applicable116,75618-Dec-200721:04Not Applicable
Mscorlib.dll2.0.50727.30684,546,56001-Oct-200822:27x86
Normidna.nlpNot Applicable59,34218-Dec-200721:05Not Applicable
Normnfc.nlpNot Applicable45,79418-Dec-200721:05Not Applicable
Normnfd.nlpNot Applicable39,28418-Dec-200721:05Not Applicable
Normnfkc.nlpNot Applicable66,38418-Dec-200721:05Not Applicable
Normnfkd.nlpNot Applicable60,29418-Dec-200721:05Not Applicable
Prc.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Prcp.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Sortkey.nlpNot Applicable262,14818-Dec-200721:05Not Applicable
Sorttbls.nlpNot Applicable20,32018-Dec-200721:05Not Applicable
Xjis.nlpNot Applicable28,28818-Dec-200721:05Not Applicable
Mscordacwks.dll2.0.50727.3068992,26401-Oct-200822:27x86
Mscorjit.dll2.0.50727.3068367,10424-Sep-200822:21x86
Mscorwks.dll2.0.50727.30685,815,80801-Oct-200822:27x86
Windows Vista SP1 and Windows Server 2008, x64 versions
File nameFile versionFile sizeDateTimePlatform
Big5.nlpNot Applicable66,72818-Dec-200721:01Not Applicable
Bopomofo.nlpNot Applicable82,17218-Dec-200721:01Not Applicable
Ksc.nlpNot Applicable116,75618-Dec-200721:02Not Applicable
Mscorlib.dll2.0.50727.30684,562,94401-Oct-200822:25x64
Normidna.nlpNot Applicable59,34218-Dec-200721:03Not Applicable
Normnfc.nlpNot Applicable45,79418-Dec-200721:03Not Applicable
Normnfd.nlpNot Applicable39,28418-Dec-200721:03Not Applicable
Normnfkc.nlpNot Applicable66,38418-Dec-200721:03Not Applicable
Normnfkd.nlpNot Applicable60,29418-Dec-200721:03Not Applicable
Prc.nlpNot Applicable83,74818-Dec-200721:03Not Applicable
Prcp.nlpNot Applicable83,74818-Dec-200721:03Not Applicable
Sortkey.nlpNot Applicable262,14818-Dec-200721:03Not Applicable
Sorttbls.nlpNot Applicable20,32018-Dec-200721:03Not Applicable
Xjis.nlpNot Applicable28,28818-Dec-200721:03Not Applicable
Mscordacwks.dll2.0.50727.30681,767,94401-Oct-200822:25x64
Mscorjit.dll2.0.50727.30681,580,03224-Sep-200823:06x64
Mscorwks.dll2.0.50727.306810,079,74401-Oct-200822:25x64
Mscorlib.resources.dll2.0.50727.3053352,25615-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053303,10415-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053315,39227-Jul-200818:02x86
Mscorlib.resources.dll2.0.50727.3053425,98415-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053307,20027-Jul-200818:02x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053311,29627-Jul-200818:02x86
Mscorlib.resources.dll2.0.50727.3053331,77615-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053315,39215-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053307,20027-Jul-200817:56x86
Mscorlib.resources.dll2.0.50727.3053348,16027-Jul-200818:02x86
Mscorlib.resources.dll2.0.50727.3053319,48827-Jul-200817:56x86
Mscorlib.resources.dll2.0.50727.3053290,81615-Sep-200822:26x86
Mscorlib.resources.dll2.0.50727.3053303,10415-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053311,29615-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053303,10427-Jul-200817:56x86
Mscorlib.resources.dll2.0.50727.3053307,20015-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.1434397,31211-Jan-200822:59x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053299,00815-Sep-200822:25x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:56x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:56x86
Big5.nlpNot Applicable66,72818-Dec-200721:03Not Applicable
Bopomofo.nlpNot Applicable82,17218-Dec-200721:03Not Applicable
Ksc.nlpNot Applicable116,75618-Dec-200721:04Not Applicable
Mscorlib.dll2.0.50727.30684,546,56001-Oct-200822:27x86
Normidna.nlpNot Applicable59,34218-Dec-200721:05Not Applicable
Normnfc.nlpNot Applicable45,79418-Dec-200721:05Not Applicable
Normnfd.nlpNot Applicable39,28418-Dec-200721:05Not Applicable
Normnfkc.nlpNot Applicable66,38418-Dec-200721:05Not Applicable
Normnfkd.nlpNot Applicable60,29418-Dec-200721:05Not Applicable
Prc.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Prcp.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Sortkey.nlpNot Applicable262,14818-Dec-200721:05Not Applicable
Sorttbls.nlpNot Applicable20,32018-Dec-200721:05Not Applicable
Xjis.nlpNot Applicable28,28818-Dec-200721:05Not Applicable
Mscordacwks.dll2.0.50727.3068992,26401-Oct-200822:27x86
Mscorjit.dll2.0.50727.3068367,10424-Sep-200822:21x86
Mscorwks.dll2.0.50727.30685,815,80801-Oct-200822:27x86
Windows Vista SP1 and Windows Server 2008, IA-64 versions
File nameFile versionFile sizeDateTimePlatform
Big5.nlpNot Applicable66,72818-Dec-200721:06Not Applicable
Bopomofo.nlpNot Applicable82,17218-Dec-200721:06Not Applicable
Ksc.nlpNot Applicable116,75618-Dec-200721:06Not Applicable
Mscorlib.dll2.0.50727.30684,005,88801-Oct-200822:26IA-64
Normidna.nlpNot Applicable59,34218-Dec-200721:08Not Applicable
Normnfc.nlpNot Applicable45,79418-Dec-200721:08Not Applicable
Normnfd.nlpNot Applicable39,28418-Dec-200721:08Not Applicable
Normnfkc.nlpNot Applicable66,38418-Dec-200721:08Not Applicable
Normnfkd.nlpNot Applicable60,29418-Dec-200721:08Not Applicable
Prc.nlpNot Applicable83,74818-Dec-200721:08Not Applicable
Prcp.nlpNot Applicable83,74818-Dec-200721:08Not Applicable
Sortkey.nlpNot Applicable262,14818-Dec-200721:08Not Applicable
Sorttbls.nlpNot Applicable20,32018-Dec-200721:08Not Applicable
Xjis.nlpNot Applicable28,28818-Dec-200721:08Not Applicable
Mscordacwks.dll2.0.50727.30683,087,88001-Oct-200822:26IA-64
Mscorjit.dll2.0.50727.30682,560,51224-Sep-200823:14IA-64
Mscorwks.dll2.0.50727.306820,153,85601-Oct-200822:26IA-64
Mscorlib.resources.dll2.0.50727.3053315,39227-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053311,29627-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053348,16027-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053319,48827-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:58x86
Mscorlib.resources.dll2.0.50727.3053278,52827-Jul-200817:59x86
Big5.nlpNot Applicable66,72818-Dec-200721:03Not Applicable
Bopomofo.nlpNot Applicable82,17218-Dec-200721:03Not Applicable
Ksc.nlpNot Applicable116,75618-Dec-200721:04Not Applicable
Mscorlib.dll2.0.50727.30684,546,56001-Oct-200822:27x86
Normidna.nlpNot Applicable59,34218-Dec-200721:05Not Applicable
Normnfc.nlpNot Applicable45,79418-Dec-200721:05Not Applicable
Normnfd.nlpNot Applicable39,28418-Dec-200721:05Not Applicable
Normnfkc.nlpNot Applicable66,38418-Dec-200721:05Not Applicable
Normnfkd.nlpNot Applicable60,29418-Dec-200721:05Not Applicable
Prc.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Prcp.nlpNot Applicable83,74818-Dec-200721:05Not Applicable
Sortkey.nlpNot Applicable262,14818-Dec-200721:05Not Applicable
Sorttbls.nlpNot Applicable20,32018-Dec-200721:05Not Applicable
Xjis.nlpNot Applicable28,28818-Dec-200721:05Not Applicable
Mscordacwks.dll2.0.50727.3068992,26401-Oct-200822:27x86
Mscorjit.dll2.0.50727.3068367,10424-Sep-200822:21x86
Mscorwks.dll2.0.50727.30685,815,80801-Oct-200822:27x86

↑ Back to the top


Workaround

To work around this problem, use one of the following methods.

Method 1

If the application code resembles the sample code in the "More Information" section, locate the following line of code.
#define GETVECTOR3D(vec3d) (*reinterpret_cast<AcGeVector3d*>(&((vec3d).m_x))
Change this line of code as follows.
#define GETVECTOR3D(vec3d) (*reinterpret_cast<AcGeVector3d*>(&((vec3d)))

Method 2

Deploy an .ini file. To do this, create a file that contains the following code.
[.NET Framework Debugging Control]
AllowOptimize=0
Name the .ini file the same as the problematic module, but use the .ini extension instead of the .dll extension. For example, for the sample code in the "More Information" section, name the .ini file the Bug.ini file. Put the Bug.ini file in the same directory as the Bug.dll file.

Note The drawback of this method is the potential performance effect for no optimizations. If you use the Native Image Generator (Ngen.exe) to precompile the module, this method is not applicable.

Method 3

Selectively apply the NoOptimization option of the MethodImplOptions enumeration to the problematic methods by using the MethodImplAttribute class.

Note This method disables the optimizations for the JIT compiler and for the Native Image Generator (Ngen.exe) on a per-method level. How much the performance is affected varies, depending on the method.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


More Information

Steps to reproduce the problem

  1. Create a C++ application that is based on the .NET Framework 3.5 SP1.
  2. Add a .cpp file to the project, name this file the Bug.cpp file, and then paste the following code in the Bug.cpp file.
    #using <mscorlib.dll>
    #include <stdlib.h>
    class AcGeVector3d
    {
    double x, y, z;
    public:
    __forceinline AcGeVector3d(const AcGeVector3d& src): x(src.x),y(src.y),z(src.z)
    {
    }
    __forceinline AcGeVector3d(double xx, double yy, double zz) : x(xx),y(yy),z(zz)
    {
    }
    __forceinline AcGeVector3d operator / (double val) const
    {
    return AcGeVector3d (x/val, y/val, z/val);
    }
    };
    #define GETVECTOR3D(vec3d) (*reinterpret_cast<AcGeVector3d*>(&((vec3d).m_x)))
    namespace Geometry
    {
    [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)]
    public value class Vector3d
    {
    internal:
    double m_x, m_y, m_z;
    Vector3d(const AcGeVector3d* obj)
    {
    GETVECTOR3D(*this) = *obj;
    }
    public:
    Vector3d(double x, double y, double z):m_x(x),m_y(y), m_z(z) {}
    Vector3d DivideBy(double value)
    {
    return Vector3d(&GETVECTOR3D(*this).operator /(value));
    }
    virtual System::String^ ToString() override
    {
    return System::String::Format("{0}, {1}, {2}", m_x, m_y, m_z);
    }
    };
    }
  3. To compile the Bug.cpp file, run the following command:
    cl /clr /GL /O2 bug.cpp /link /dll /out:bug.dll
  4. Create a new Microsoft Visual C# project to be used as the client project.
  5. Name the code file the Test.cs file, and then paste the following code in the Test.cs file.
    using Geometry;
    namespace Test
    {
    class Tester
    {
    static void Main()
    {
    Vector3d v = new Vector3d(200, 200, 0);
    v = v.DivideBy(150);
    System.Console.WriteLine("{0}", v);
    }
    }
    }
  6. To compile the Test.cs file, run the following command:
    csc /r:bug.dll test.cs
  7. To embed the manifest into the Test.exe file, run the following command:
    mt.exe -nologo -manifest bug.dll.manifest -outputresource:test.exe;1
  8. Run the Test.exe file.
Notice that the actual result is as follows:
1.33333333333333, 1.333333333333, 0
However, the expected result is as follows:
1.33333333333333, 0, 0

↑ Back to the top


References

For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates

↑ Back to the top


Keywords: kb, kbnotautohotfix, kbhotfixdev, kbexpertiseadvanced, kbfix, kbqfe, kbhotfixserver

↑ Back to the top

Article Info
Article ID : 957542
Revision : 1
Created on : 1/7/2017
Published on : 10/8/2011
Exists online : False
Views : 418