www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8199] New: scope exit breaks stack alignment

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8199

           Summary: scope exit breaks stack alignment
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: FreeBSD
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dawg dawgfoto.de



cat > bug.d << CODE
void checkAlign()
{
    asm
    {
        naked;
        mov RDI, RSP;
        and RDI, 0xF;
        cmp RDI, 0x8;
        je Lpass;
        hlt;
    Lpass:
        ret;
    }
}

void foo()
{
}

void main()
{
    checkAlign();
    scope(exit) checkAlign();
    foo();
}
CODE

dmd -run bug

----

The scope exit pushes the address of the return block onto the stack
which breaks the stack alignment.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 05 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8199


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
           Severity|normal                      |major



https://github.com/D-Programming-Language/dmd/pull/988

This bug affects all calls from a finally block that require an aligned stack.
The "optimization" is also a huge performance hog. Abusing return as indirect
jump always incurs a branch misprediction.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 14 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8199




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4e8cc86f5acc600511a4e12caab802b99d836c9b
fix Issue 8199 - stack is not aligned in finally block

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8199




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2b3a94d50f2d31410c9a1f70dfb5ead7f31b4a27
fix Issue 8199 - stack is not aligned in finally block

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 21 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8199


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 21 2012