Thread overview
[Issue 6698] New: Regression(2.053): segfault with naked asm in inner function
Sep 20, 2011
Don
Sep 20, 2011
Don
Oct 18, 2011
Don
Oct 24, 2011
Don
Oct 24, 2011
Walter Bright
September 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6698

           Summary: Regression(2.053): segfault with naked asm in inner
                    function
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2011-09-20 05:04:39 PDT ---
This comes from the test suite, fail_compilation/fail135.d
The code actually worked for a very long time (since around DMD1.000), but
wasn't compiling because it had a missing import for printf.


// segfault on 0.150
void fail135()
{
    int i = 0;

    void fn()
    {
    asm
    {
        naked;
        lea EAX, i;
        mov [EAX], 42;
        ret;
    }
    }
    fn();
    assert(i==42);
}

void main()
{
    fail135();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6698


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
           Severity|normal                      |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6698



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-10-17 23:32:27 PDT ---
I'm actually not sure if this should really work, or not. It may simply be code
that was relying on undefined behaviour.
Despite nominally being a "regression", it should be given low priority.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6698



--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-10-24 02:01:24 PDT ---
This is not caused by the compiler. The change seems to have been caused by a change in druntime between 2.052 and 2.053.

This code didn't actually work before. If you change the assert to:

assert(i==49);
(which should fail), it doesn't fail!

This code is actually clobbering the return address.

The test case is bug 701, which hasn't been fixed. The bug is that this test case is in the test suite.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6698


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2011-10-24 13:39:10 PDT ---
https://github.com/D-Programming-Language/dmd/commit/9224e1cae4b0d08898f4ee737c1ea510fc84fbdc

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