Hi all.
I just modified the Jit_GetField32 helper function to make a call out to C++
function, and now I get a ton of assertions like this:
Assert failure(PID 2108 [0x0000083c], Thread: 2456 [0x998]):
!GetThread()->GCFor
bidden()
File:
c:\home\chris\projects\rotor\src\sscli\clr\src\vm\rotor_x86\../i386/excepx86
.cpp, Line: 592 Image:
C:\Home\Chris\Projects\Rotor\src\sscli\build\v1.x86chk.rotor\clix.exe
I thought the whole point of the helper function frame was to take care of
this stuff. What do I need to do to either 1) say that GC is forbidden here,
but it's ok, or 2) not forbid the GC.
I put my call just before the call to FC_GC_POLL_RET() at the end of
JIT_GetField32 (jitinterface.cpp, line 5480); it's just:
objRef->Release();
where Release is a new member function of class object that I've added
previously; here's the code for that:
void Object::Release()
{
LONG *pRefCount = FindRefCount();
if( pRefCount != 0 && *pRefCount != 0 )
{
_ASSERTE( *pRefCount > 0 );
LONG newref = InterlockedDecrement( pRefCount );
#ifdef _DEBUG
RC_LOG(( LF_REFCOUNT, LL_REFCOUNT, "Release on object at %p of type
%s, refcount now %d\n", this, GetClass()->GetDebugClassName(), newref ));
#else
RC_LOG(( LF_REFCOUNT, LL_REFCOUNT, "Release on object at %p,
refcount now %d\n", this, newref ));
#endif
if( newref == 0 )
{
#ifdef _DEBUG
RC_LOG((LF_REFCOUNT, LL_REFCOUNT, "Object at %p of type %s
refcount now 0, finalizing\n", this, GetClass()->GetDebugClassName() ));
#else
RC_LOG((LF_REFCOUNT, LL_REFCOUNT, "Object at %p refcount now 0,
finalizing\n", this ));
#endif
}
}
All it's doing is decrementing a long and doing some logging. It will do
some more work in the future (calling the finalizer for one) so some
suggestions that would allow calls back into managed code from this function
would be very helpful.
Any suggestions?
Thanks,
-Chris