Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed: SymWriter COM object is not released on exception (#955)
* Fixed: SymWriter COM object is not released on exception The Problem: Problem observed when being used in coverlet: coverlet-coverage/coverlet#1471 If an exception caused `NativePdbWriter.Write` to never be called, it would not call `SymWriter.Close`, which in turn meant `Marshal.ReleaseComObject` was left uncalled. The garbage collector will eventually destroy the object and thereby release the COM object, but that happens non-deterministically. The COM object is holding to a file handle, which prevents other operations on the written file until it is released. The result was random file access issues. The Solution: Luckily NativePdbWriter is IDisposable. I added a call to `writer.Close` there. But now it could be called twice, so I had to add a boolean to SymWriter to avoid releasing everything twice. * Code style --------- Co-authored-by: Jb Evain <[email protected]>
- Loading branch information