AA struct hashing bug?

Random D user via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 8 03:45:25 PST 2015


On Tuesday, 8 December 2015 at 11:04:49 UTC, Random D user wrote:
> I need to look into this more.

Ok. This is minimal app that crashes for me. If someone could try 
this:

class App
{
     this()
     {
     }

     void crash( int val )
     in
     {
         assert( val == 1 );
     }
     body
     {
         struct Foo
         {
             this( int k )
             {
                 a = k;
             }
             int a;
         }

         Foo foo;
         int[ Foo ] map;

         map[ foo ] = 1;  // Crash! bug?
     }
}

int main( char[][] args )
{
     App a = new App;
     a.crash( 1 );

     return 0;
}

And the previous case for the crash looks like this:
asm:
_D6object14TypeInfo_Class7getHashMxFNbNexPvZm:
00007ff6d9e4b500  push rbp
00007ff6d9e4b501  mov rbp, rsp
00007ff6d9e4b504  sub rsp, 0x30
00007ff6d9e4b508  mov [rbp-0x8], rsi
00007ff6d9e4b50c  mov rsi, [rdx]
00007ff6d9e4b50f  test rsi, rsi
00007ff6d9e4b512  jz 
_D6object14TypeInfo_Class7getHashMxFNbNexPvZm+0x20 
(0x7ff6d9e4b520)
00007ff6d9e4b514  mov rcx, rsi
00007ff6d9e4b517  mov rax, [rsi]
00007ff6d9e4b51a  call qword near [rax+0x10] <---------------- 
crash here
00007ff6d9e4b51e  jmp 
_D6object14TypeInfo_Class7getHashMxFNbNexPvZm+0x22 
(0x7ff6d9e4b522)
00007ff6d9e4b520  xor eax, eax
00007ff6d9e4b522  mov rsi, [rbp-0x8]
00007ff6d9e4b526  lea rsp, [rbp]
00007ff6d9e4b52a  pop rbp

stack:
0000000000000000	
_D6object14TypeInfo_Class7getHashMxFNbNexPvZm() + 0x1e bytes	D
_D6object14TypeInfo_Const7getHashMxFNbNfxPvZm() + 0x13 bytes	D
application.Application.startup.Foo.__xtoHash( 
application.Application.startup.Foo* p, ulong h ) + 0x55 bytes	D
_D6object15TypeInfo_Struct7getHashMxFNaNbNfxPvZm() + 0x22 bytes	D
_aaGetY() + 0xa0 bytes	D
application.Application.startup() Line 159 + 0x26 bytes	D


More information about the Digitalmars-d-learn mailing list