www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11528] New: appender: crash with -inline -O

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

           Summary: appender: crash with -inline -O
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: r.sagitario gmx.de


--- Comment #0 from Rainer Schuetze <r.sagitario gmx.de> 2013-11-16 08:29:39
PST ---
This program is tweaked to cause a crash when building for Win32:

import std.array;

void main()
{
    auto arr = appender!string();
    asm { mov EBX,-1; }
    arr.put("1");
}

dmd -inline -O -g test.d
test
object.Error: Integer Divide by Zero ---------------- 0x004222B6 in _ULDIV 0x00404D2A in stdarrayAppender at m:\s\d\rainers\phobos\std\array.d(2453) 0x004234C0 in memset 0x0040F76E in _d_newitemT 0x00405AC0 in stdarrayAppender at m:\s\d\rainers\phobos\std\array.d(2339) 0x0040E5F8 in rtdmain2_d_run_mainrunAll__lambda1 0x0040E5CB in rtdmain2_d_run_mainrunAll 0x0040E4E1 in _d_run_main 0x0040CD90 in main at M:\s\d\rainers\bugs\rs165\test.d(3) 0x75EC850D in BaseThreadInitThunk 0x77DDBF39 in RtlInitializeExceptionChain 0x77DDBF0C in RtlInitializeExceptionChain This is caused by the bsr intrinsic having undefined behaviour for 0 (i.e. the previous value of the destination register is preserved). -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 16 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11528


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #1 from Rainer Schuetze <r.sagitario gmx.de> 2013-11-16 08:39:59
PST ---
https://github.com/D-Programming-Language/phobos/pull/1695

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11528



--- Comment #2 from github-bugzilla puremagic.com 2013-11-17 04:13:55 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/ec5e25b7967e5cd36db4db4964fd2f09f62565e7
Merge pull request #1695 from rainers/issue_11528

fix issue 11528: crashes or undefined behaviour of appender's first allocation

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11528


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11528


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com


--- Comment #3 from monarchdodra gmail.com 2013-11-17 06:43:34 PST ---
(In reply to comment #0)
 This program is tweaked to cause a crash when building for Win32:
 
 import std.array;
 
 void main()
 {
     auto arr = appender!string();
     asm { mov EBX,-1; }
     arr.put("1");
 }
 
dmd -inline -O -g test.d
test
object.Error: Integer Divide by Zero
Out of curiosity, did you "encounter" this bug out in the wild, and reduce it to this, or did you see it in the code, and write this specifically? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 17 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11528



--- Comment #4 from Rainer Schuetze <r.sagitario gmx.de> 2013-11-17 09:28:34
PST ---
(In reply to comment #3)
 Out of curiosity, did you "encounter" this bug out in the wild, and reduce it
 to this, or did you see it in the code, and write this specifically?
It caused initialization of Visual D to crash, but only the optimized release build. I checked the commit history, and it seemed that the change was introduced after 2.064 was built. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 17 2013