Clearly, the finalizer thread completes the installation of SafeHandle, which is already located. This is the implementation of the AesCryptoServiceProvider.Dispose (bool) method:
protected override void Dispose(bool disposing) { try { if (disposing) { if (this.m_key != null) this.m_key.Dispose(); if (this.m_cspHandle != null) this.m_cspHandle.Dispose(); } } finally { base.Dispose(disposing); } }
Three errors:
- It does not set the m_key field to null after deleting it
- GC.SuppressFinalize () is not called, even by a base class in .NET 3.5
- The SafeCapiKeyHandle class does not cancel the stored handle in the ReleaseHandle () method.
The combination of all three errors is enough to run this MDA. It is still bugged in .NET 4.0, but at least GC.SuppressFinalize is called by SymmetricAlgorithm.Dispose (bool), so the finalizer will not be used.
Inspiring the frame masters to screw. You can report this problem on connect.microsoft.com. To stop the debugger from scuffling, you use Debug + Exceptions, Managed Debugging Assistants, untick ReleaseHandleFailed about this. By default, this person will not be knocked over, probably the reason you first noticed this error.
I think that the third error makes this problem critical; it is technically possible for this error to close the return descriptor value. However, the chances are very small. Pretty ironic considering this is a safe class of descriptors.
source share