Skip to content

tests: free sandbox repositories with cl_git_sandbox_cleanup - #7409

Open
msuozzo wants to merge 1 commit into
libgit2:mainfrom
msuozzo:push-mrpsrpxzxlzz
Open

msuozzo wants to merge 1 commit into
libgit2:mainfrom
msuozzo:push-mrpsrpxzxlzz

Conversation

@msuozzo

@msuozzo msuozzo commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

clone::nonetwork::clone_tag_to_tree, repo::getters::commit_parents and worktree::worktree::list_without_worktrees free the repository that cl_git_sandbox_init returned, but clar still points at it, and their suites' cleanup doesn't call cl_git_sandbox_cleanup. The next cl_git_sandbox_init replaces the pointer, but a cleanup that calls cl_git_sandbox_cleanup first frees the repository again. Running clone::nonetwork::clone_tag_to_tree and then network::fetchlocal under ASan reports a heap-use-after-free in git_repository_free.

This uses cl_git_sandbox_cleanup instead, which frees the repository, forgets it and removes the sandbox.

The worktree fixture does the same with the repositories it opens; #7411 fixes that separately.

clone::nonetwork::clone_tag_to_tree, repo::getters::commit_parents and
worktree::worktree::list_without_worktrees free the repository that
cl_git_sandbox_init returned, but clar still points at it, and their
suites' cleanup doesn't call cl_git_sandbox_cleanup. The next
cl_git_sandbox_init replaces the pointer, but a cleanup that calls
cl_git_sandbox_cleanup first frees the repository again: running
clone::nonetwork::clone_tag_to_tree and then network::fetchlocal under
ASan reports a heap-use-after-free in git_repository_free.

Use cl_git_sandbox_cleanup, which frees the repository, forgets it and
removes the sandbox.
@msuozzo msuozzo changed the title tests: free sandbox repositories with cl_git_sandbox_cleanup tests: stop freeing sandbox repositories twice Oct 12, 2026
@msuozzo msuozzo changed the title tests: stop freeing sandbox repositories twice tests: free sandbox repositories with cl_git_sandbox_cleanup Oct 12, 2026

This branch has not been deployed

No deployments
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.

1 participant