Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup! scalar: add the cache-server command #653

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

derrickstolee
Copy link
Collaborator

A user reported that a use of 'scalar cache-server --set ...' on Linux resulted in a failure with message

  munmap_chunk(): invalid pointer
  Aborted (core dumped)

It turns out that the cmd_cache_server() method has several invalid mechanisms around command parsing. Specifically in this case, it is attempting to free() the strings that are loaded from command-line options. These strings are not actually owned by the process and should not be freed. In fact, they should be stored as 'const' pointers to make the compiler complain about freeing them.

There are a few other things that also seemed odd that I took the liberty to fix while here. For one, the "--list" option used a nonstandard version of OPT_STRING() only so it could set "(default)" as the value when no string is provided. However, this does not work as expected, and "--list" always requires a value. Make that explicit.

Add tests that check some of the critical paths of this command, including the "--list" command querying the gvfs/config endpoint of the remote URL. This works even without using "scalar clone --gvfs-protocol" because it is only setting Git config as an end-result.


  • This change only applies to interactions with Azure DevOps and the
    GVFS Protocol.

A user reported that a use of 'scalar cache-server --set ...' on Linux
resulted in a failure with message

  munmap_chunk(): invalid pointer
  Aborted (core dumped)

It turns out that the cmd_cache_server() method has several invalid
mechanisms around command parsing. Specifically in this case, it is
attempting to free() the strings that are loaded from command-line
options. These strings are not actually owned by the process and should
not be freed. In fact, they should be stored as 'const' pointers to make
the compiler complain about freeing them.

There are a few other things that also seemed odd that I took the
liberty to fix while here. For one, the "--list" option used a
nonstandard version of OPT_STRING() only so it could set "(default)" as
the value when no string is provided. However, this does not work as
expected, and "--list" always requires a value. Make that explicit.

Add tests that check some of the critical paths of this command,
including the "--list" command querying the gvfs/config endpoint of the
remote URL. This works even without using "scalar clone --gvfs-protocol"
because it is only setting Git config as an end-result.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee self-assigned this May 31, 2024
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

BTW don't worry about the PR build failure, it'll be fixed via git-for-windows@f01301a in vfs-2.45.2

@dscho dscho merged commit bc6cc5f into microsoft:vfs-2.45.1 Jun 3, 2024
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants