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

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.

Cause

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

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:

http://code.msdn.microsoft.com/KB957542
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:

http://support.microsoft.com/contactus/?ws=supportNote 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 name

File version

File size

Date

Time

Mscordacwks.dll

2.0.50727.3068

992,264

16-Sep-2008

13:13

Mscorjit.dll

2.0.50727.3068

367,104

16-Sep-2008

13:13

Mscorlib.dll

2.0.50727.3068

4,546,560

16-Sep-2008

13:13

Mscorwks.dll

2.0.50727.3068

5,815,808

16-Sep-2008

13:13

Windows 2000, Windows XP, and Windows Server 2003, x64 versions

File name

File version

File size

Date

Time

Platform

Mscordacwks.dll

2.0.50727.3068

992,264

16-Sep-2008

13:13

x86

Mscorjit.dll

2.0.50727.3068

367,104

16-Sep-2008

13:13

x86

Mscorlib.dll

2.0.50727.3068

4,546,560

16-Sep-2008

13:13

x86

Mscorwks.dll

2.0.50727.3068

5,815,808

16-Sep-2008

13:13

x86

Mscordacwks.dll

2.0.50727.3068

1,767,944

16-Sep-2008

10:33

x64

Mscorjit.dll

2.0.50727.3068

1,580,032

16-Sep-2008

10:33

x64

Mscorlib.dll

2.0.50727.3068

4,562,944

16-Sep-2008

10:33

x64

Mscorwks.dll

2.0.50727.3068

10,079,744

16-Sep-2008

10:33

x64

Windows 2000, Windows XP, and Windows Server 2003, IA-64 versions

File name

File version

File size

Date

Time

Platform

Mscordacwks.dll

2.0.50727.3068

992,264

16-Sep-2008

13:13

x86

Mscorjit.dll

2.0.50727.3068

367,104

16-Sep-2008

13:13

x86

Mscorlib.dll

2.0.50727.3068

4,546,560

16-Sep-2008

13:13

x86

Mscorwks.dll

2.0.50727.3068

5,815,808

16-Sep-2008

13:13

x86

Mscordacwks.dll

2.0.50727.3068

3,087,880

16-Sep-2008

10:44

IA-64

Mscorjit.dll

2.0.50727.3068

2,560,512

16-Sep-2008

10:44

IA-64

Mscorlib.dll

2.0.50727.3068

4,005,888

16-Sep-2008

10:44

IA-64

Mscorwks.dll

2.0.50727.3068

20,153,856

16-Sep-2008

10:44

IA-64

Windows Vista Service Pack 1 (SP1) and Windows Server 2008, x86 versions

File name

File version

File size

Date

Time

Platform

Mscorlib.resources.dll

2.0.50727.3053

352,256

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

315,392

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

425,984

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

311,296

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

331,776

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

315,392

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

27-Jul-2008

17:55

x86

Mscorlib.resources.dll

2.0.50727.3053

348,160

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

319,488

27-Jul-2008

17:55

x86

Mscorlib.resources.dll

2.0.50727.3053

290,816

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

311,296

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

27-Jul-2008

17:55

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.1434

397,312

11-Jan-2008

22:59

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:55

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:55

x86

Big5.nlp

Not Applicable

66,728

18-Dec-2007

21:03

Not Applicable

Bopomofo.nlp

Not Applicable

82,172

18-Dec-2007

21:03

Not Applicable

Ksc.nlp

Not Applicable

116,756

18-Dec-2007

21:04

Not Applicable

Mscorlib.dll

2.0.50727.3068

4,546,560

01-Oct-2008

22:27

x86

Normidna.nlp

Not Applicable

59,342

18-Dec-2007

21:05

Not Applicable

Normnfc.nlp

Not Applicable

45,794

18-Dec-2007

21:05

Not Applicable

Normnfd.nlp

Not Applicable

39,284

18-Dec-2007

21:05

Not Applicable

Normnfkc.nlp

Not Applicable

66,384

18-Dec-2007

21:05

Not Applicable

Normnfkd.nlp

Not Applicable

60,294

18-Dec-2007

21:05

Not Applicable

Prc.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Prcp.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Sortkey.nlp

Not Applicable

262,148

18-Dec-2007

21:05

Not Applicable

Sorttbls.nlp

Not Applicable

20,320

18-Dec-2007

21:05

Not Applicable

Xjis.nlp

Not Applicable

28,288

18-Dec-2007

21:05

Not Applicable

Mscordacwks.dll

2.0.50727.3068

992,264

01-Oct-2008

22:27

x86

Mscorjit.dll

2.0.50727.3068

367,104

24-Sep-2008

22:21

x86

Mscorwks.dll

2.0.50727.3068

5,815,808

01-Oct-2008

22:27

x86

Windows Vista SP1 and Windows Server 2008, x64 versions

File name

File version

File size

Date

Time

Platform

Big5.nlp

Not Applicable

66,728

18-Dec-2007

21:01

Not Applicable

Bopomofo.nlp

Not Applicable

82,172

18-Dec-2007

21:01

Not Applicable

Ksc.nlp

Not Applicable

116,756

18-Dec-2007

21:02

Not Applicable

Mscorlib.dll

2.0.50727.3068

4,562,944

01-Oct-2008

22:25

x64

Normidna.nlp

Not Applicable

59,342

18-Dec-2007

21:03

Not Applicable

Normnfc.nlp

Not Applicable

45,794

18-Dec-2007

21:03

Not Applicable

Normnfd.nlp

Not Applicable

39,284

18-Dec-2007

21:03

Not Applicable

Normnfkc.nlp

Not Applicable

66,384

18-Dec-2007

21:03

Not Applicable

Normnfkd.nlp

Not Applicable

60,294

18-Dec-2007

21:03

Not Applicable

Prc.nlp

Not Applicable

83,748

18-Dec-2007

21:03

Not Applicable

Prcp.nlp

Not Applicable

83,748

18-Dec-2007

21:03

Not Applicable

Sortkey.nlp

Not Applicable

262,148

18-Dec-2007

21:03

Not Applicable

Sorttbls.nlp

Not Applicable

20,320

18-Dec-2007

21:03

Not Applicable

Xjis.nlp

Not Applicable

28,288

18-Dec-2007

21:03

Not Applicable

Mscordacwks.dll

2.0.50727.3068

1,767,944

01-Oct-2008

22:25

x64

Mscorjit.dll

2.0.50727.3068

1,580,032

24-Sep-2008

23:06

x64

Mscorwks.dll

2.0.50727.3068

10,079,744

01-Oct-2008

22:25

x64

Mscorlib.resources.dll

2.0.50727.3053

352,256

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

315,392

27-Jul-2008

18:02

x86

Mscorlib.resources.dll

2.0.50727.3053

425,984

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

27-Jul-2008

18:02

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

311,296

27-Jul-2008

18:02

x86

Mscorlib.resources.dll

2.0.50727.3053

331,776

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

315,392

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

27-Jul-2008

17:56

x86

Mscorlib.resources.dll

2.0.50727.3053

348,160

27-Jul-2008

18:02

x86

Mscorlib.resources.dll

2.0.50727.3053

319,488

27-Jul-2008

17:56

x86

Mscorlib.resources.dll

2.0.50727.3053

290,816

15-Sep-2008

22:26

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

311,296

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

303,104

27-Jul-2008

17:56

x86

Mscorlib.resources.dll

2.0.50727.3053

307,200

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.1434

397,312

11-Jan-2008

22:59

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

299,008

15-Sep-2008

22:25

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:56

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:56

x86

Big5.nlp

Not Applicable

66,728

18-Dec-2007

21:03

Not Applicable

Bopomofo.nlp

Not Applicable

82,172

18-Dec-2007

21:03

Not Applicable

Ksc.nlp

Not Applicable

116,756

18-Dec-2007

21:04

Not Applicable

Mscorlib.dll

2.0.50727.3068

4,546,560

01-Oct-2008

22:27

x86

Normidna.nlp

Not Applicable

59,342

18-Dec-2007

21:05

Not Applicable

Normnfc.nlp

Not Applicable

45,794

18-Dec-2007

21:05

Not Applicable

Normnfd.nlp

Not Applicable

39,284

18-Dec-2007

21:05

Not Applicable

Normnfkc.nlp

Not Applicable

66,384

18-Dec-2007

21:05

Not Applicable

Normnfkd.nlp

Not Applicable

60,294

18-Dec-2007

21:05

Not Applicable

Prc.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Prcp.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Sortkey.nlp

Not Applicable

262,148

18-Dec-2007

21:05

Not Applicable

Sorttbls.nlp

Not Applicable

20,320

18-Dec-2007

21:05

Not Applicable

Xjis.nlp

Not Applicable

28,288

18-Dec-2007

21:05

Not Applicable

Mscordacwks.dll

2.0.50727.3068

992,264

01-Oct-2008

22:27

x86

Mscorjit.dll

2.0.50727.3068

367,104

24-Sep-2008

22:21

x86

Mscorwks.dll

2.0.50727.3068

5,815,808

01-Oct-2008

22:27

x86

Windows Vista SP1 and Windows Server 2008, IA-64 versions

File name

File version

File size

Date

Time

Platform

Big5.nlp

Not Applicable

66,728

18-Dec-2007

21:06

Not Applicable

Bopomofo.nlp

Not Applicable

82,172

18-Dec-2007

21:06

Not Applicable

Ksc.nlp

Not Applicable

116,756

18-Dec-2007

21:06

Not Applicable

Mscorlib.dll

2.0.50727.3068

4,005,888

01-Oct-2008

22:26

IA-64

Normidna.nlp

Not Applicable

59,342

18-Dec-2007

21:08

Not Applicable

Normnfc.nlp

Not Applicable

45,794

18-Dec-2007

21:08

Not Applicable

Normnfd.nlp

Not Applicable

39,284

18-Dec-2007

21:08

Not Applicable

Normnfkc.nlp

Not Applicable

66,384

18-Dec-2007

21:08

Not Applicable

Normnfkd.nlp

Not Applicable

60,294

18-Dec-2007

21:08

Not Applicable

Prc.nlp

Not Applicable

83,748

18-Dec-2007

21:08

Not Applicable

Prcp.nlp

Not Applicable

83,748

18-Dec-2007

21:08

Not Applicable

Sortkey.nlp

Not Applicable

262,148

18-Dec-2007

21:08

Not Applicable

Sorttbls.nlp

Not Applicable

20,320

18-Dec-2007

21:08

Not Applicable

Xjis.nlp

Not Applicable

28,288

18-Dec-2007

21:08

Not Applicable

Mscordacwks.dll

2.0.50727.3068

3,087,880

01-Oct-2008

22:26

IA-64

Mscorjit.dll

2.0.50727.3068

2,560,512

24-Sep-2008

23:14

IA-64

Mscorwks.dll

2.0.50727.3068

20,153,856

01-Oct-2008

22:26

IA-64

Mscorlib.resources.dll

2.0.50727.3053

315,392

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

311,296

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

348,160

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

319,488

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:58

x86

Mscorlib.resources.dll

2.0.50727.3053

278,528

27-Jul-2008

17:59

x86

Big5.nlp

Not Applicable

66,728

18-Dec-2007

21:03

Not Applicable

Bopomofo.nlp

Not Applicable

82,172

18-Dec-2007

21:03

Not Applicable

Ksc.nlp

Not Applicable

116,756

18-Dec-2007

21:04

Not Applicable

Mscorlib.dll

2.0.50727.3068

4,546,560

01-Oct-2008

22:27

x86

Normidna.nlp

Not Applicable

59,342

18-Dec-2007

21:05

Not Applicable

Normnfc.nlp

Not Applicable

45,794

18-Dec-2007

21:05

Not Applicable

Normnfd.nlp

Not Applicable

39,284

18-Dec-2007

21:05

Not Applicable

Normnfkc.nlp

Not Applicable

66,384

18-Dec-2007

21:05

Not Applicable

Normnfkd.nlp

Not Applicable

60,294

18-Dec-2007

21:05

Not Applicable

Prc.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Prcp.nlp

Not Applicable

83,748

18-Dec-2007

21:05

Not Applicable

Sortkey.nlp

Not Applicable

262,148

18-Dec-2007

21:05

Not Applicable

Sorttbls.nlp

Not Applicable

20,320

18-Dec-2007

21:05

Not Applicable

Xjis.nlp

Not Applicable

28,288

18-Dec-2007

21:05

Not Applicable

Mscordacwks.dll

2.0.50727.3068

992,264

01-Oct-2008

22:27

x86

Mscorjit.dll

2.0.50727.3068

367,104

24-Sep-2008

22:21

x86

Mscorwks.dll

2.0.50727.3068

5,815,808

01-Oct-2008

22:27

x86

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.

Status

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

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

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

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×