Search

C++ compiler generates incorrect movups instructions iso movss by Arjan Mels

Closed
as Fixed Help for as Fixed

3
0
Sign in
to vote
Type: Bug
ID: 548432
Opened: 4/3/2010 3:06:03 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The C++ compiler generates incorrect movups (8-byte write) instructions instead of movss (4-byte write) instructions in e.g. D3DXMatrixIdentity function. This causes corrupting the stack corruption etc.

It occurs with the following flag settings: using /Zp1 or /Zp2 option in combination with /arch:SSE or /arch:SSE2 option in debug mode (/Od).

I guess this movups instruction is chosen because it can handle unaligned accesses, however it moves 8-bytes iso. 4.

BTW. I used the February 2010 DirectX SDK
Details (expand)

Product Language

English

Version

Visual Studio 2010 Release Candidate

Operating System

Windows 7

Operating System Language

English

Steps to Reproduce

The following code incombination with flags /Od, /Zp1, /arch:SSE (and the rest at their default, including the runtime checks) (See also the attached project which reproduces the error):

#include <tchar.h>
#include <stdio.h>
#include <d3dx9.h>

int __cdecl _tmain(int argc, _TCHAR* argv[])
{
    int a=0xaaaaaaaa;
    D3DXMATRIXA16 mat;
    int b=0xbbbbbbbb;
    
    D3DXMatrixIdentity(&mat);

    printf("Element _11: %lf\n",mat._11);

    if (a != 0xaaaaaaaa)
        printf("variable a corrupted!!!\n");
    if (b != 0xbbbbbbbb)
        printf("variable b corrupted!!!\n");
    
    if (a==0xaaaaaaaa && b==0xbbbbbbbb)
        printf("Everything OK.\n");

    return 0;
}

Actual Results

Results in a pop-up:

Run-Time Check Failure #2 - Stack around the variable 'mat' was corrupted.

When looking at the disassembly movups instructions are generated.

Expected Results

No error message & movss instructions.
      You can indicate your satisfaction with how Microsoft handled this issue by completing this quick 3 question survey. [Details]

 

File Attachments
File Name Submitted By Submitted On File Size  
bug_movups.zip 4/3/2010 14 KB
Sign in to post a comment.
Posted by Arjan Mels on 5/2/2010 at 4:01 AM
Great. Thanks for the feedback. When is SP1 planned? (Well I'll just stick with 2005 for my production work till 2010 SP1 is released otherwise. Although I love the improvements in the 2010 version, especially the performance tools for multithreading is great.)

Regards,

Arjan
Posted by Microsoft on 4/21/2010 at 6:41 PM
Hi, thanks for reporting this bug. The bug is fixed in our development branch, but unfortunately the fix did not make it in time for inclusion in VS 2010. I will mark the fix for possible inclusion in the next service pack, otherwise the fix will definitely be in the next major release of VS. Thanks for reporting it, although we'd already discovered the bug through our internal testing, the person who fixed the bug thought it was a rare occurence. Obviously hitting it in dx9 raises the likelihood of getting the fix in VS 2010 SP1.
Posted by Microsoft on 4/5/2010 at 11:16 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you
Posted by Microsoft on 4/4/2010 at 4:03 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.