Bug 25132

Summary: SafeHandle always called with Disposed(true)
Product: [Mono] Class Libraries Reporter: Marius Ungureanu <marius.ungureanu>
Component: mscorlibAssignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: masafa, mono-bugs+mono
Priority: ---    
Version: unspecified   
Target Milestone: Untriaged   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:

Description Marius Ungureanu 2014-12-06 19:50:49 UTC
In [1] we're trying to add some leaks handling in LibGit2Sharp. Based on debugging, I noticed that SafeHandle.Dispose(bool) is always called with true, so code at [2] is not gathering any leaks, whilst it does on .NET. Compare [3] and [4].

Probably as easy as importing reference source?

[1] - https://github.com/libgit2/libgit2sharp/pull/883
[2] - https://github.com/libgit2/libgit2sharp/blob/ntk/leaks/LibGit2Sharp/Core/Handles/SafeHandleBase.cs#L93-L102
[3] - https://ci.appveyor.com/project/nulltoken/libgit2sharp/build/108/job/0hywvy5jgksvsxtt
[4] - https://travis-ci.org/libgit2/libgit2sharp/jobs/43222585
Comment 1 Marek Safar 2014-12-08 04:17:25 UTC
I'd need some help to track down what is the source of the issue.

Firstly. SafeHandle.Dispose(true) only means that the handle is disposed manually (which is good) and not via GC.

The link at [2] is not working for me and some sort of repro (small if possible) would be helpful.
Comment 2 Marius Ungureanu 2014-12-08 09:09:05 UTC
This is the code, sorry. The PR got merged.

https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp/Core/Handles/SafeHandleBase.cs#L107-L129
Comment 3 Marius Ungureanu 2014-12-08 09:47:05 UTC
I've set up a test repository to show this bug. MS.NET throws an exception, Mono does not.

https://github.com/Therzok/TestSafeHandle
Comment 4 Marek Safar 2014-12-08 11:51:53 UTC
Fixed in master