libgit2 / libgit2/libgit2sharp

Access Violation on pushing to a new remote

Đang mở
#1,981 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
3.5k
Fork
925
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện quy trình push được cung cấp trên Windows 10 với .NET 6, tập trung vào repository.Network.Push và thao tác truy cập branch.IsTracking được hiển thị trong stack trace. Kiểm tra Branch.ResolveTrackedBranch và lệnh gọi git_branch_upstream_name; hoàn tất khi một branch cục bộ chưa được theo dõi tạo ra lỗi thông thường thay vì lỗi vi phạm quyền truy cập.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, git
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.