libgit2 / libgit2/libgit2sharp

Consider using SafeHandle in Libgit2Object instead of void*

未关闭
#2,111 8 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
3.5k
派生
925
PR 合并指标
30 天内没有已合并 PR

描述

We've had a couple of bug reports against dotnet/runtime with rarely-reproduceable crashes coming from libgit2sharp. We believe that one possible reason could be an interop anti-pattern in Libgit2Object - void*/IntPtr representation of a native handle that can be freed in finalizer. E.g. in this case the finalizer in Libgit2Object may end up calling native free here (and other overloads).

The reason why it's called an anti-pattern can be explained by a short repro in this issue: https://github.com/dotnet/runtime/issues/103522 and a general solution is to use SafeHandle for such handles. Also, see https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices

Reproduction steps
Expected behavior
Actual behavior
Version of LibGit2Sharp (release number or SHA1)
Operating system(s) tested; .NET runtime tested

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 LibGit2Sharp/Core/Handles/Libgit2Object.cs 第 88 行附近开始,然后跟踪 LibGit2Sharp/Core/Handles/Objects.cs 第 502-505 行附近的 finalizer 和 native-free overloads。将这些 ownership 路径与 SafeHandle 指南及链接的 runtime 报告进行比较。完成的标准是:相关的 native handle 生命周期路径得到安全表示并被释放,且不会出现报告中的 finalizer race。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, git
领域
devtools
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。