Skip to content
Open
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/SOS/SOS.Hosting/RuntimeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ protected override void Destroy()
}
if (_dacHandle != IntPtr.Zero)
{
DataTarget.PlatformFunctions.FreeLibrary(_dacHandle);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want to use cDac with older versions of SOS that won't have this change?

cDAC hosted under NativeAOT could call LoadLibrary() on itself to bump the reference count up. That should prevent the OS from trying to unload it regardless whether SOS calls FreeLibrary().

// Previously, the DAC was freed here, but as we transition to the cDAC which uses NativeAOT,
// it is no longer possible to free the DAC library when it is using the shimmed cDAC.
_dacHandle = IntPtr.Zero;
}
if (_cdacHandle != IntPtr.Zero)
{
DataTarget.PlatformFunctions.FreeLibrary(_cdacHandle);
// cDAC can not be freed because it is a NativeAOT dll.
_cdacHandle = IntPtr.Zero;
}
if (_dbiHandle != IntPtr.Zero)
Expand Down