Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashing bug in finalizer #460

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions src/DTF/Libraries/Compression.Cab/CabPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,11 @@ protected override void Dispose(bool disposing)
{
try
{
if (disposing)
// See comment in CabUnpacker.Dispose for more info.
if (this.fciHandle != null)
{
if (this.fciHandle != null)
{
this.fciHandle.Dispose();
this.fciHandle = null;
}
this.fciHandle.Dispose();
this.fciHandle = null;
}
}
finally
Expand Down
14 changes: 8 additions & 6 deletions src/DTF/Libraries/Compression.Cab/CabUnpacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,15 @@ protected override void Dispose(bool disposing)
{
try
{
if (disposing)
// While fdiHandle is a SafeHandle, it will callback to C# method from this instance
// when releasing handle, and since finalizers execute in nondeterministic order, if
// the handle's finalizer runs after this instance, it will get exception and crash
// the process. Therefore we must release this handle regardless of the 'disposing'
// flag.
if (this.fdiHandle != null)
{
if (this.fdiHandle != null)
{
this.fdiHandle.Dispose();
this.fdiHandle = null;
}
this.fdiHandle.Dispose();
this.fdiHandle = null;
}
}
finally
Expand Down