[Issue 9677] Crash on setting length property of array VC 2012 64 bit

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 10 01:15:52 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9677


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |r.sagitario at gmx.de
           Severity|normal                      |critical


--- Comment #1 from Rainer Schuetze <r.sagitario at gmx.de> 2013-03-10 01:15:51 PST ---
This is actually a codegen bug that just happens to be exposed by TLS memory
being in memory above 4GB with VS2012.

Reduced test case:

/////////////////////// 8< //////////
module lifetime;

int *__blkcache_storage;
size_t __nextBlkIdx;

/**
 * Resize dynamic arrays with 0 initializers.
 */
void _d_arraysetlengthT(size_t newlength)
{
    asm
    {
        mov RAX, newlength;
    }

    auto cache = __blkcache_storage;
    int *curpos = cache + __nextBlkIdx;
    *curpos = 0;
}
/////////////////////// >8 //////////

"dmd -c -O -m64 lifetime.d" creates this code:

_D8lifetime18_d_arraysetlengthTFmZv:
  0000000000000000: 55                 push        rbp
  0000000000000001: 48 8B EC           mov         rbp,rsp
  0000000000000004: 48 83 EC 10        sub         rsp,10h
  0000000000000008: 53                 push        rbx
  0000000000000009: 48 89 4D 10        mov         qword ptr [rbp+10h],rcx
  000000000000000D: 48 8B 45 10        mov         rax,qword ptr [rbp+10h]
  0000000000000011: 8B 05 00 00 00 00  mov         eax,dword ptr [_tls_index]
  0000000000000017: 65 48 8B 14 25 58  mov         rdx,qword ptr gs:[58h]
                    00 00 00
  0000000000000020: 48 8D 04 C2        lea         eax,[rdx+rax*8]
  0000000000000024: 48 8B 10           mov         rdx,qword ptr [rax]
  0000000000000027: BB 00 00 00 00     mov         ebx,offset
_D8lifetime18__blkcache_storagePi
  000000000000002C: 48 8B 14 1A        mov         rdx,qword ptr [rdx+rbx]
  0000000000000030: 48 89 55 F8        mov         qword ptr [rbp-8],rdx
  0000000000000034: 48 8B 00           mov         rax,qword ptr [rax]
  0000000000000037: BA 00 00 00 00     mov         edx,offset
_D8lifetime12__nextBlkIdxm
  000000000000003C: 48 8B 04 10        mov         rax,qword ptr [rax+rdx]
  0000000000000040: 48 8B 55 F8        mov         rdx,qword ptr [rbp-8]
  0000000000000044: 48 8D 04 82        lea         rax,[rdx+rax*4]
  0000000000000048: 48 89 45 F0        mov         qword ptr [rbp-10h],rax
  000000000000004C: 48 8B 45 F0        mov         rax,qword ptr [rbp-10h]
  0000000000000050: C7 00 00 00 00 00  mov         dword ptr [rax],0
  0000000000000056: 5B                 pop         rbx
  0000000000000057: 48 8D 65 00        lea         rsp,[rbp]
  000000000000005B: 5D                 pop         rbp
  000000000000005C: C3                 ret

Note the "eax" assignment at offset 0x20, it should be rax.

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


More information about the Digitalmars-d-bugs mailing list