Thread overview
Access violation
May 23, 2006
Lionello Lunesu
Re: Access violation (in _d_invariant)
May 23, 2006
Lionello Lunesu
May 24, 2006
Lionello Lunesu
May 29, 2006
Walter Bright
May 23, 2006
I'm making a small 1-file http server but I get an access violation when a client requests a big document (~480KB).

disassembly:
_D9invariant12_d_invariantFC6ObjectZv:
00403620  push        eax
00403621  mov         ecx,dword ptr [eax]
00403623  push        ebx
00403624  mov         ebx,dword ptr [ecx]

registers:
EAX = 01BC3420 EBX = 00418214 ECX = 00000000 EDX = 00402124
ESI = 00402124 EDI = 01B93A30 EIP = 00403624 ESP = 01F1F78C
EBP = 01F1F7A0 EFL = 00010206

call stack:
httpd.exe!_D9invariant12_d_invariantFC6ObjectZv()  + 0x4 bytes
httpd.exe!__d_callfinalizer()  + 0x46 bytes
httpd.exe!_D3std2gc13new_finalizerFPvPvZv()  + 0x9 bytes
httpd.exe!_D3gcx3Gcx8bigAllocFkZPv()  + 0x60 bytes
01cc0000()

system:
WinXP x64 Pro
dmd v0.157
debugger VS2005

The code is hardly readable! I was just playing around with some socket stuff. It's another test program gone bezerk.

I have no idea why it's crashing. I see "bigAlloc" and it must be the allocation of the 480KB needed for the document (std.file.read).

L.


May 23, 2006
I've recompiled phobos/dmgc with -g -debug and got some more debug info.

void _d_invariant(Object o)
004057A0  enter       8,0
004057A4  push        ebx
004057A5  push        esi
004057A6  mov         dword ptr [ebp-8],eax
{   ClassInfo c;
004057A9  mov         dword ptr [c],0

    //printf("__d_invariant(%p)\n", o);

    // BUG: needs to be filename/line of caller, not library routine
    assert(o !is null);	// just do null check, not invariant check
004057B0  cmp         dword ptr [o],0
004057B4  jne         +20h (4057C0h)
004057B6  mov         eax,0Eh
004057BB  call        _assert_9invariant (4057F0h)

    c = o.classinfo;
004057C0  mov         ecx,dword ptr [o]
004057C3  mov         edx,dword ptr [ecx]
>>>004057C5  mov         ebx,dword ptr [edx]


EAX = 01C64AC0 EBX = 00439214 ECX = 01C64AC0 EDX = 00000000
ESI = 00402124 EDI = 01C33A30 EIP = 004057C5
ESP = 0781F740 EBP = 0781F750 EFL = 00010206


void _d_invariant(Object o)
{   ClassInfo c;

    //printf("__d_invariant(%p)\n", o);

    // BUG: needs to be filename/line of caller, not library routine
    assert(o !is null);	// just do null check, not invariant check

>>>    c = o.classinfo;
    do
    {
	if (c.classInvariant)
	{
	    (*c.classInvariant)(o);
	}
	c = c.base;
    } while (c);
}

'o' is set, but its vptr is null; also o.monitor is null.

Lio.

By the way, I had to tweak quite a lot in win32.mak to get it to work :S
May 24, 2006
Seems to be a problem in the GC.

I noticed I'm not saving the Thread pointer anyway. When I create a Thread[] list and add the new threads to the list, the problem doesn't happen.

The strange thing is that Thread.getAll() DOES contain the thread, so it shouldn't have been collected in the first place.

Is the Thread.getAll() array not scanned by the GC?

L.
May 29, 2006
Lionello Lunesu wrote:
 > 'o' is set, but its vptr is null; also o.monitor is null.

I'd start tracking it backwards to find out where o got set with a null vptr.