git-ecosystem / git-ecosystem/git-credential-manager

"fatal: Value cannot be null (Parameter 'ptr')" on macOS during git-gvfs-helper

Open
#1,531 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auth-issue bug
Dominant language
C#
Stars
9.3k
Forks
2.9k
Avg merge
7d 1h
Merged PRs (30d)
14

Description

Version

2.4.1

Operating system

macOS

OS version or distribution

(unknown at this time)

Git hosting provider(s)

Azure DevOps

Other hosting provider

(Plus GVFS Protocol)

(Azure DevOps only) What format is your remote URL?

https://{organization}.visualstudio.com/DefaultCollection/...

Can you access the remote repository directly in the browser?

Yes, I can access the repository

Expected behavior

Doing a git pull authenticates and succeeds.

Actual behavior

GCM fails (returns code -1 in Program.cs) with this error message:

fatal: Value cannot be null (Parameter 'ptr')
Logs

While poking around the code (I'm unable to debug on behalf of this user) I found what I think is the only case where a macOS client could pass a null value into a method that has a ptr parameter:

In src/shared/Core/Interop/MacOS/MacOSKeychain.cs:

// Check if an entry already exists in the keychain
int findResult = SecKeychainFindGenericPassword(
    IntPtr.Zero, serviceNameLength, serviceName, accountLength, account,
    out uint passwordDataLength, out passwordData, out itemRef);

switch (findResult)
{
    // Update existing entry only if the password/secret is different
    case OK when !InteropUtils.AreEqual(secretBytes, passwordData, passwordDataLength):
        ThrowIfError(
            SecKeychainItemModifyAttributesAndData(itemRef, IntPtr.Zero, (uint) secretBytes.Length, secretBytes),
            "Could not update existing item"
        );
        break;

The InteropUtils.AreEqual() method takes passwordData directly from the out-parameter in the external method SecKeychainFindGenericPassword() without validation. I'm not sure if this is the issue or what could cause that problem, but hopefully this gives some help towards discovering the problem.

Please see the attached trace.txt given by setting GIT_TRACE2_PERF="$(pwd)/trace.txt" on the git pull calls.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached trace.txt and the git pull authentication path in Program.cs, then inspect src/shared/Core/Interop/MacOS/MacOSKeychain.cs and InteropUtils.AreEqual around SecKeychainFindGenericPassword. Confirm whether the out passwordData value can cause the reported null-pointer error and verify that an Azure DevOps pull succeeds on macOS without returning code -1.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git, macos
Domain
authentication, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.