[Local GC] Fix a number of handle table interface violations (#12277)
authorSean Gillespie <segilles@microsoft.com>
Thu, 15 Jun 2017 19:45:12 +0000 (12:45 -0700)
committerGitHub <noreply@github.com>
Thu, 15 Jun 2017 19:45:12 +0000 (12:45 -0700)
* Fix a smattering of GC handle table interface violations

Stub out a few other handle violations

* [Local GC] Add SetExtraInfoForHandle onto GC handle manager interface

* [Local GC] Changes uses of HndGetHandleADIndex to GetHandleContext

* Add HandleGetType to GC handle table interface

1) Change IGCHandleManager methods that take "int" to represent the type of a handle to HandleType, and fix callers to cast to HandleType
2) Add HandleFetchType to IGCHandleManager, returning a HandleType
3) Fix uses of handtablepriv's HandleFetchType and remove the GC directory from the include path

* 9 -> HNDTYPE_WEAK_WINRT, 0 -> HNDTYPE_WEAK_SHORT in assert

14 files changed:
src/debug/ee/debugger.cpp
src/gc/gchandletable.cpp
src/gc/gchandletableimpl.h
src/gc/gcinterface.h
src/vm/CMakeLists.txt
src/vm/appdomain.cpp
src/vm/appdomain.hpp
src/vm/encee.cpp
src/vm/gcenv.os.cpp
src/vm/gcheaputilities.cpp
src/vm/marshalnative.cpp
src/vm/rcwrefcache.cpp
src/vm/runtimehandles.cpp
src/vm/weakreferencenative.cpp

index f8ebfc5..fdbbe69 100644 (file)
@@ -10999,7 +10999,8 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
             if(fValid)
             {
                 // Get the appdomain
-                ADIndex appDomainIndex = HndGetHandleADIndex(objectHandle);
+                IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+                ADIndex appDomainIndex = ADIndex(reinterpret_cast<DWORD>(mgr->GetHandleContext(objectHandle)));
                 pAppDomain = SystemDomain::GetAppDomainAtIndex(appDomainIndex);
 
                 _ASSERTE(pAppDomain != NULL);
index 63f2f79..38ca0cd 100644 (file)
@@ -7,6 +7,7 @@
 #include "gcenv.h"
 #include "gchandletableimpl.h"
 #include "objecthandle.h"
+#include "handletablepriv.h"
 
 GCHandleStore* g_gcGlobalHandleStore;
 
@@ -25,19 +26,19 @@ bool GCHandleStore::ContainsHandle(OBJECTHANDLE handle)
     return _underlyingBucket.Contains(handle);
 }
 
-OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type)
+OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, HandleType type)
 {
     HHANDLETABLE handletable = _underlyingBucket.pTable[GetCurrentThreadHomeHeapNumber()];
     return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object));
 }
 
-OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo)
+OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo)
 {
     HHANDLETABLE handletable = _underlyingBucket.pTable[heapToAffinitizeTo];
     return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object));
 }
 
-OBJECTHANDLE GCHandleStore::CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo)
+OBJECTHANDLE GCHandleStore::CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo)
 {
     HHANDLETABLE handletable = _underlyingBucket.pTable[GetCurrentThreadHomeHeapNumber()];
     return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object), reinterpret_cast<uintptr_t>(pExtraInfo));
@@ -124,7 +125,7 @@ void* GCHandleManager::GetHandleContext(OBJECTHANDLE handle)
     return (void*)((uintptr_t)::HndGetHandleTableADIndex(::HndGetHandleTable(handle)).m_dwIndex);
 }
 
-OBJECTHANDLE GCHandleManager::CreateGlobalHandleOfType(Object* object, int type)
+OBJECTHANDLE GCHandleManager::CreateGlobalHandleOfType(Object* object, HandleType type)
 {
     return ::HndCreateHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], type, ObjectToOBJECTREF(object)); 
 }
@@ -134,7 +135,7 @@ OBJECTHANDLE GCHandleManager::CreateDuplicateHandle(OBJECTHANDLE handle)
     return ::HndCreateHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, ::HndFetchHandle(handle));
 }
 
-void GCHandleManager::DestroyHandleOfType(OBJECTHANDLE handle, int type)
+void GCHandleManager::DestroyHandleOfType(OBJECTHANDLE handle, HandleType type)
 {
     ::HndDestroyHandle(::HndGetHandleTable(handle), type, handle);
 }
@@ -144,6 +145,11 @@ void GCHandleManager::DestroyHandleOfUnknownType(OBJECTHANDLE handle)
     ::HndDestroyHandleOfUnknownType(::HndGetHandleTable(handle), handle);
 }
 
+void GCHandleManager::SetExtraInfoForHandle(OBJECTHANDLE  handle, HandleType type, void* pExtraInfo)
+{
+    ::HndSetHandleExtraInfo(handle, type, (uintptr_t)pExtraInfo);
+}
+
 void* GCHandleManager::GetExtraInfoFromHandle(OBJECTHANDLE handle)
 {
     return (void*)::HndGetHandleExtraInfo(handle);
@@ -173,3 +179,11 @@ Object* GCHandleManager::InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE h
 {
     return (Object*)::HndInterlockedCompareExchangeHandle(handle, ObjectToOBJECTREF(object), ObjectToOBJECTREF(comparandObject));
 }
+
+HandleType GCHandleManager::HandleFetchType(OBJECTHANDLE handle)
+{
+    uint32_t type = ::HandleFetchType(handle);
+    assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_WEAK_WINRT);
+    return static_cast<HandleType>(type);
+}
+
index 4be346f..288927c 100644 (file)
@@ -15,11 +15,11 @@ public:
 
     virtual bool ContainsHandle(OBJECTHANDLE handle);
 
-    virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type);
+    virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type);
 
-    virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo);
+    virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo);
 
-    virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo);
+    virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo);
 
     virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary);
 
@@ -49,14 +49,16 @@ public:
 
     virtual void DestroyHandleStore(IGCHandleStore* store);
 
-    virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type);
+    virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, HandleType type);
 
     virtual OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle);
 
-    virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type);
+    virtual void DestroyHandleOfType(OBJECTHANDLE handle, HandleType type);
 
     virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
 
+    virtual void SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo);
+
     virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
 
     virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object);
@@ -68,6 +70,8 @@ public:
     virtual Object* GetDependentHandleSecondary(OBJECTHANDLE handle);
 
     virtual Object* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject);
+
+    virtual HandleType HandleFetchType(OBJECTHANDLE handle);
 };
 
 #endif  // GCHANDLETABLE_H_
index aefa84b..e474ee2 100644 (file)
@@ -413,11 +413,11 @@ public:
 
     virtual bool ContainsHandle(OBJECTHANDLE handle) = 0;
 
-    virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type) = 0;
+    virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type) = 0;
 
-    virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo) = 0;
+    virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo) = 0;
 
-    virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo) = 0;
+    virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo) = 0;
 
     virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary) = 0;
 
@@ -443,14 +443,16 @@ public:
 
     virtual void DestroyHandleStore(IGCHandleStore* store) = 0;
 
-    virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type) = 0;
+    virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, HandleType type) = 0;
 
     virtual OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle) = 0;
 
-    virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type) = 0;
+    virtual void DestroyHandleOfType(OBJECTHANDLE handle, HandleType type) = 0;
 
     virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0;
 
+    virtual void SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo) = 0;
+
     virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0;
 
     virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object) = 0;
@@ -462,6 +464,8 @@ public:
     virtual Object* GetDependentHandleSecondary(OBJECTHANDLE handle) = 0;
 
     virtual Object* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject) = 0;
+
+    virtual HandleType HandleFetchType(OBJECTHANDLE handle) = 0;
 };
 
 // IGCHeap is the interface that the VM will use when interacting with the GC.
index 4e6a523..7d5ea89 100644 (file)
@@ -2,9 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 # Needed due to the cmunged files being in the binary folders, the set(CMAKE_INCLUDE_CURRENT_DIR ON) is not enough
 include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}) 
-
-include_directories(${CLR_DIR}/src/gc)
-
 include_directories(${ARCH_SOURCES_DIR})
 
 add_definitions(-DUNICODE)
index 56b5aa1..ee495f1 100644 (file)
@@ -1749,7 +1749,8 @@ void AppDomain::CacheWinRTFactoryObject(MethodTable *pClassMT, OBJECTREF *refFac
         pNewCtxEntry = pEntry->m_pCtxEntry;
         pEntry->m_pCtxEntry = pTemp;
 
-        HndAssignHandle(pEntry->m_ohFactoryObject, *refFactory);
+        IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+        mgr->StoreObjectInHandle(pEntry->m_ohFactoryObject, OBJECTREFToObject(*refFactory));
     }
 }
 
@@ -4153,12 +4154,6 @@ AppDomain::~AppDomain()
 //*****************************************************************************
 //*****************************************************************************
 //*****************************************************************************
-#ifdef _DEBUG
-#include "handletablepriv.h"
-#endif
-
-
-
 void AppDomain::Init()
 {
     CONTRACTL
index edd638e..18bc73e 100644 (file)
@@ -1237,7 +1237,7 @@ public:
     // Handles
 
 #if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
-    OBJECTHANDLE CreateTypedHandle(OBJECTREF object, int type)
+    OBJECTHANDLE CreateTypedHandle(OBJECTREF object, HandleType type)
     {
         WRAPPER_NO_CONTRACT;
 
index 7f12643..b1315dd 100644 (file)
@@ -1139,7 +1139,8 @@ EnCAddedField *EnCAddedField::Allocate(OBJECTREF thisPointer, EnCFieldDesc *pFD)
         FieldDesc *pHelperField = MscorlibBinder::GetField(FIELD__ENC_HELPER__OBJECT_REFERENCE);
 
         // store the empty boxed object into the helper object
-        OBJECTREF pHelperObj = GetDependentHandleSecondary(pEntry->m_FieldData);
+        IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+        OBJECTREF pHelperObj = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));
         OBJECTREF *pHelperRef = (OBJECTREF *)pHelperField->GetAddress( pHelperObj->GetAddress() );
         SetObjectReference( pHelperRef, obj, pDomain );
 
@@ -1244,7 +1245,8 @@ PTR_CBYTE EnCSyncBlockInfo::ResolveField(OBJECTREF thisPointer, EnCFieldDesc *pF
 
     // we found a matching entry in the list of EnCAddedFields
     // Get the EnC helper object (see the detailed description in Allocate above)
-    OBJECTREF pHelper = GetDependentHandleSecondary(pEntry->m_FieldData);           
+    IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+    OBJECTREF pHelper = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));
     _ASSERTE(pHelper != NULL);
 
     FieldDesc *pHelperFieldDesc = NULL;
@@ -1333,7 +1335,8 @@ PTR_CBYTE EnCSyncBlockInfo::ResolveOrAllocateField(OBJECTREF thisPointer, EnCFie
 
     // we found a matching entry in the list of EnCAddedFields
     // Get the EnC helper object (see the detailed description in Allocate above)
-    OBJECTREF pHelper = GetDependentHandleSecondary(pEntry->m_FieldData);           
+    IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+    OBJECTREF pHelper = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));           
     _ASSERTE(pHelper != NULL);
 
     FieldDesc * pHelperField = NULL;
index 8572551..bb75f01 100644 (file)
@@ -22,7 +22,7 @@
 #undef Sleep
 #endif // Sleep
 
-#include "env/gcenv.os.h"
+#include "../gc/env/gcenv.os.h"
 
 #define MAX_PTR ((uint8_t*)(~(ptrdiff_t)0))
 
index cd7afed..d0bfda6 100644 (file)
@@ -78,7 +78,8 @@ void ValidateHandleAssignment(OBJECTHANDLE handle, OBJECTREF objRef)
     _ASSERTE("Attempt to access destroyed handle." && *(_UNCHECKED_OBJECTREF*)handle != DEBUG_DestroyedHandleValue);
 #endif
 
-    ADIndex appDomainIndex = HndGetHandleADIndex(handle);
+    IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+    ADIndex appDomainIndex = ADIndex(reinterpret_cast<DWORD>(mgr->GetHandleContext(handle)));
 
     AppDomain *unloadingDomain = SystemDomain::AppDomainBeingUnloaded();
     if (unloadingDomain && unloadingDomain->GetIndex() == appDomainIndex && unloadingDomain->NoAccessToHandleTable())
@@ -88,4 +89,4 @@ void ValidateHandleAssignment(OBJECTHANDLE handle, OBJECTREF objRef)
 
     ValidateObjectAndAppDomain(objRef, appDomainIndex);
 #endif // _DEBUG_IMPL
-}
\ No newline at end of file
+}
index 17f3945..8aebd9a 100644 (file)
@@ -35,7 +35,6 @@
 #include "fcall.h"
 #include "dllimportcallback.h"
 #include "comdelegate.h"
-#include "handletablepriv.h"
 #include "mdaassistants.h"
 #include "typestring.h"
 #include "appdomain.inl"
@@ -640,13 +639,14 @@ FCIMPL2(LPVOID, MarshalNative::GCHandleInternalAlloc, Object *obj, int type)
     OBJECTHANDLE hnd = 0;
 
     HELPER_METHOD_FRAME_BEGIN_RET_NOPOLL();
-    
+
     // If it is a pinned handle, check the object type.
     if (type == HNDTYPE_PINNED)
         GCHandleValidatePinnedObject(objRef);
 
+    assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_WEAK_WINRT);
     // Create the handle.
-    hnd = GetAppDomain()->CreateTypedHandle(objRef, type);
+    hnd = GetAppDomain()->CreateTypedHandle(objRef, static_cast<HandleType>(type));
 
     HELPER_METHOD_FRAME_END_POLL();
     return (LPVOID) hnd;
@@ -764,7 +764,7 @@ FCIMPL1(INT32, MarshalNative::GCHandleInternalGetHandleType, OBJECTHANDLE handle
 {
     FCALL_CONTRACT;
 
-    return HandleFetchType(handle);
+    return GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handle);
 }
 FCIMPLEND
 
index 328dc4a..acb174d 100644 (file)
@@ -176,8 +176,9 @@ void RCWRefCache::ShrinkDependentHandles()
     {
         OBJECTHANDLE depHnd = m_depHndList[i];
         
-        HndAssignHandle(depHnd, NULL);
-        SetDependentHandleSecondary(depHnd, NULL);        
+        IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+        mgr->StoreObjectInHandle(depHnd, NULL);
+        mgr->SetDependentHandleSecondary(depHnd, NULL);
             
         LOG((LF_INTEROP, LL_INFO1000, "\t[RCWRefCache 0x%p] DependentHandle 0x%p cleared @ index %d\n", this, depHnd, (ULONG) i));
     }
@@ -266,8 +267,9 @@ HRESULT RCWRefCache::AddReferenceUsingDependentHandle(RCW *pRCW, ComCallWrapper
         // Yes, there is a valid DependentHandle entry on the list, use that
         OBJECTHANDLE depHnd = (OBJECTHANDLE) m_depHndList[m_dwDepHndListFreeIndex];
 
-        HndAssignHandle(depHnd, pRCW->GetExposedObject());
-        SetDependentHandleSecondary(depHnd, pCCW->GetObjectRef());
+        IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+        mgr->StoreObjectInHandle(depHnd, OBJECTREFToObject(pRCW->GetExposedObject()));
+        mgr->SetDependentHandleSecondary(depHnd, OBJECTREFToObject(pCCW->GetObjectRef()));
 
         STRESS_LOG3(
             LF_INTEROP, LL_INFO1000, 
index fa0feb8..da47cc9 100644 (file)
@@ -1152,7 +1152,8 @@ PVOID QCALLTYPE RuntimeTypeHandle::GetGCHandle(EnregisteredTypeHandle pTypeHandl
     GCX_COOP();
 
     TypeHandle th = TypeHandle::FromPtr(pTypeHandle);
-    objHandle = th.GetDomain()->CreateTypedHandle(NULL, handleType);
+    assert(handleType >= HNDTYPE_WEAK_SHORT && handleType <= HNDTYPE_WEAK_WINRT);
+    objHandle = th.GetDomain()->CreateTypedHandle(NULL, static_cast<HandleType>(handleType));
     th.GetLoaderAllocator()->RegisterHandleForCleanup(objHandle);
 
     END_QCALL;
index b7052b8..05640be 100644 (file)
@@ -11,8 +11,8 @@
 
 #include "common.h"
 
+#include "gchandleutilities.h"
 #include "weakreferencenative.h"
-#include "handletablepriv.h"
 #include "typestring.h"
 #include "typeparse.h"
 
@@ -218,7 +218,7 @@ NOINLINE Object* LoadWinRTWeakReferenceTarget(WEAKREFERENCEREF weakReference, Ty
             }
             else if(IsWinRTWeakReferenceHandle(handle.RawHandle))
             {
-                _ASSERTE(HandleFetchType(handle.Handle) == HNDTYPE_WEAK_WINRT);
+                _ASSERTE(GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handle.Handle) == HNDTYPE_WEAK_WINRT);
 
                 // Retrieve the associated IWeakReference* for this weak reference.  Add a reference to it while we release
                 // the spin lock so that another thread doesn't release it out from underneath us.
@@ -227,7 +227,8 @@ NOINLINE Object* LoadWinRTWeakReferenceTarget(WEAKREFERENCEREF weakReference, Ty
                 // it's always set to NULL here and there's nothing for it to release.
                 _ASSERTE(pWinRTWeakReference.IsNull());
                 CONTRACT_VIOLATION(GCViolation);
-                pWinRTWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle.Handle));
+                IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+                pWinRTWeakReference = reinterpret_cast<IWeakReference*>(mgr->GetExtraInfoFromHandle(handle.Handle));
                 if (!pWinRTWeakReference.IsNull())
                 {
                     pWinRTWeakReference->AddRef();
@@ -508,7 +509,7 @@ void FinalizeWeakReference(Object * obj)
         handleToDestroy = GetHandleValue(handle);
 
         // Cache the old handle value
-        UINT handleType = HandleFetchType(handleToDestroy);
+        HandleType handleType = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handleToDestroy);
 #ifdef FEATURE_COMINTEROP
         _ASSERTE(handleType == HNDTYPE_WEAK_LONG || handleType == HNDTYPE_WEAK_SHORT || handleType == HNDTYPE_WEAK_WINRT);
         isWeakWinRTHandle = handleType == HNDTYPE_WEAK_WINRT;
@@ -755,8 +756,9 @@ NOINLINE void SetWeakReferenceTarget(WEAKREFERENCEREF weakReference, OBJECTREF t
         // and update it with the new weak reference pointer.  If the incoming object is not an RCW that can
         // use IWeakReference, then pTargetWeakReference will be null.  Therefore, no matter what the incoming
         // object type is, we can unconditionally store pTargetWeakReference to the object handle's extra data.
-        IWeakReference* pExistingWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle.Handle));
-        HndSetHandleExtraInfo(handle.Handle, HNDTYPE_WEAK_WINRT, reinterpret_cast<LPARAM>(pTargetWeakReference.GetValue()));
+        IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+        IWeakReference* pExistingWeakReference = reinterpret_cast<IWeakReference*>(mgr->GetExtraInfoFromHandle(handle.Handle));
+        mgr->SetExtraInfoForHandle(handle.Handle, HNDTYPE_WEAK_WINRT, reinterpret_cast<void*>(pTargetWeakReference.GetValue()));
         StoreObjectInHandle(handle.Handle, target);
 
         if (pExistingWeakReference != nullptr)
@@ -931,7 +933,7 @@ FCIMPL1(FC_BOOL_RET, WeakReferenceNative::IsTrackResurrection, WeakReferenceObje
         }
         else
         {
-            trackResurrection = HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
+            trackResurrection = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
         }
 
         ReleaseWeakHandleSpinLock(pThis, handle);
@@ -969,7 +971,7 @@ FCIMPL1(FC_BOOL_RET, WeakReferenceOfTNative::IsTrackResurrection, WeakReferenceO
         }
         else
         {
-            trackResurrection = HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
+            trackResurrection = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
         }
 
         ReleaseWeakHandleSpinLock(pThis, handle);