libgit2 / libgit2/libgit2sharp
Access Violation on pushing to a new remote
未關閉
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 3.5k
- 分支
- 925
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Reproduction steps
using var repository = new Repository(_options.LocalRepositoryPath);
const string message = "message";
var commitOptions = new CommitOptions()
{
AllowEmptyCommit = false,
PrettifyMessage = true,
};
var authorSignature = new Signature(_options.Username, _options.Email, DateTimeOffset.UtcNow);
await UpdateReadmeFile();
repository.Index.Add("readme.md");
repository.Index.Write();
Commands.Stage(repository, "*");
repository.Commit(message, authorSignature, authorSignature, commitOptions);
PushOptions pushOptions = new PushOptions()
{
CredentialsProvider = (_, __, ___) => new DefaultCredentials(),
};
_logger.LogInformation("Pushing changes to remote");
_logger.LogDebug($"Branch has been tracked: {branch.IsTracking}");
repository.Network.Push(branch, pushOptions);
Expected behavior
Another error should occur when the local branch is not being tracked. But not an access violation exception.
Actual behavior
This craches with:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
at LibGit2Sharp.Core.NativeMethods.git_branch_upstream_name(LibGit2Sharp.Core.Handles.GitBuf, LibGit2Sharp.Core.git_repository*, System.String)
--------------------------------
at LibGit2Sharp.Core.Proxy.git_branch_upstream_name(LibGit2Sharp.Core.Handles.RepositoryHandle, System.String)
at LibGit2Sharp.Branch.ResolveTrackedBranch()
at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ViaFactory(System.Threading.LazyThreadSafetyMode)
at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecutionAndPublication(System.LazyHelper, Boolean)
at System.Lazy`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CreateValue()
at LibGit2Sharp.Branch.get_IsTracking()
Version of LibGit2Sharp (release number or SHA1)
Operating system(s) tested; .NET runtime tested
OS: Windows 10 Professional
.NET runtime: NET 6.0
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在 Windows 10 和 .NET 6 上重現提供的 push 流程,重點關注 repository.Network.Push 以及堆疊追蹤中顯示的對 branch.IsTracking 的存取。檢查 Branch.ResolveTrackedBranch 和 git_branch_upstream_name 呼叫;當未追蹤的本機分支產生一般錯誤而不是存取違規時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp, git
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100