Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Review feedback.
  • Loading branch information
AaronRobinsonMSFT authored and github-actions committed Sep 2, 2021
commit aa4e41b3bfe86d5ce28feaa555e58ba15606cc6a
2 changes: 1 addition & 1 deletion src/coreclr/interop/inc/interoplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace InteropLib

// Destroy the supplied wrapper.
// Optionally notify the wrapper of collection at the same time.
void DestroyWrapperForExternal(_In_ void* context, _In_ bool notifyIsCollected = false) noexcept;
void DestroyWrapperForExternal(_In_ void* context, _In_ bool notifyIsBeingCollected = false) noexcept;

// Separate the supplied wrapper from the tracker runtime.
void SeparateWrapperFromTrackerRuntime(_In_ void* context) noexcept;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/interop/interoplib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ namespace InteropLib
}
}

void DestroyWrapperForExternal(_In_ void* contextMaybe, _In_ bool notifyIsCollected) noexcept
void DestroyWrapperForExternal(_In_ void* contextMaybe, _In_ bool notifyIsBeingCollected) noexcept
{
NativeObjectWrapperContext* context = NativeObjectWrapperContext::MapFromRuntimeContext(contextMaybe);

// A caller should not be destroying a context without knowing if the context is valid.
_ASSERTE(context != nullptr);

if (notifyIsCollected)
if (notifyIsBeingCollected)
NotifyWrapperForExternalIsBeingCollected(contextMaybe);

NativeObjectWrapperContext::Destroy(context);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/interoplibinterface_comwrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ namespace
// We also request collection notification since this holder is presently
// only used for new activation of wrappers therefore the notification won't occur
// at the typical time of before finalization.
InteropLib::Com::DestroyWrapperForExternal(Result.Context, /* notifyIsCollected */ true);
InteropLib::Com::DestroyWrapperForExternal(Result.Context, /* notifyIsBeingCollected */ true);
}
}
InteropLib::Com::ExternalWrapperResult* operator&()
Expand Down
7 changes: 5 additions & 2 deletions src/tests/Interop/COM/ComWrappers/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ public static AllocationCountResult CountTrackerObjectAllocations()
[DllImport(nameof(MockReferenceTrackerRuntime))]
extern public static int TrackerTarget_ReleaseFromReferenceTracker(IntPtr ptr);

// Suppressing the GC transition here as we want to make sure we are in-sync
// with the GC which is setting the connected value.
[SuppressGCTransition]
[DllImport(nameof(MockReferenceTrackerRuntime))]
extern public static int IsWrapperConnected(IntPtr instance);
extern public static byte IsTrackerObjectConnected(IntPtr instance);
}

[Guid("42951130-245C-485E-B60B-4ED4254256F8")]
Expand Down Expand Up @@ -222,7 +225,7 @@ static IntPtr CreateInstance(IntPtr outer, out IntPtr inner)
}
else
{
int isConnected = MockReferenceTrackerRuntime.IsWrapperConnected(this.classNative.Instance);
byte isConnected = MockReferenceTrackerRuntime.IsTrackerObjectConnected(this.classNative.Instance);
if (isConnected != 0)
{
throw new Exception("TrackerObject should be disconnected prior to finalization");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ extern "C" DLL_EXPORT int STDMETHODCALLTYPE Trigger_NotifyEndOfReferenceTracking
return TrackerRuntimeManager.NotifyEndOfReferenceTrackingOnThread();
}

extern "C" DLL_EXPORT BOOL STDMETHODCALLTYPE IsWrapperConnected(IUnknown* inst)
extern "C" DLL_EXPORT bool STDMETHODCALLTYPE IsTrackerObjectConnected(IUnknown* inst)
{
auto trackerObject = reinterpret_cast<TrackerObject::TrackerObjectImpl*>(inst);
return trackerObject->IsConnected() ? TRUE : FALSE;
return trackerObject->IsConnected();
}

extern "C" DLL_EXPORT void* STDMETHODCALLTYPE TrackerTarget_AddRefFromReferenceTrackerAndReturn(IUnknown *obj)
Expand Down