Skip to content

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

@derrickstolee

Description

@derrickstolee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-issueAn issue authenticating to a hostbugA bug in Git Credential Manager

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions