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

GTRepository dealloc crash #689

Open
arguiot opened this issue May 16, 2019 · 5 comments · May be fixed by #690
Open

GTRepository dealloc crash #689

arguiot opened this issue May 16, 2019 · 5 comments · May be fixed by #690

Comments

@arguiot
Copy link

arguiot commented May 16, 2019

When the system calls -[GTRepository dealloc] and the git_repository is empty, but still exists, the app crashes.

Here is a screenshot of the debug session:
Capture d’écran 2019-05-16 à 20 27 09

What I would suggest is to change:

- (void)dealloc {
if (_git_repository != NULL) {
git_repository_free(_git_repository);
_git_repository = NULL;
}
}

By simply checking if the workdir property of the git_repository object isn't empty before cleaning the repo.

I'm not an Objective-C developer, so I let you guys do that for me (or just show me how to do it, and I'll submit a PR)

arguiot added a commit to arguiot/objective-git that referenced this issue May 16, 2019
@arguiot arguiot linked a pull request May 16, 2019 that will close this issue
@arguiot
Copy link
Author

arguiot commented May 16, 2019

Actually, I sent a PR: #690

@tiennou
Copy link
Contributor

tiennou commented May 20, 2019

Hmm, we're not supposed to care about the repository having a workdir, and I think that your proposed fix leaks the git_repository memory on bare repositories (ie. whenever workdir would have been NULL).

How you've constructed the GTRepository/git_repository itself would be most helpful, right now this could also just be a stray memory write corrupting something in the git_repository. If it's openen from a worktree (a.k.a git worktree list), or a worktree on a bare repo, would also help, as there had been a few issues in libgit2 itself.

@arguiot
Copy link
Author

arguiot commented May 22, 2019

I’m using an Opaque Pointer to create my GTRepository. I will try with a URL, to see if anything changes

@tiennou
Copy link
Contributor

tiennou commented May 22, 2019

Is that specific to a given repository, or does it happen on any of them ? Could you whip up a test case maybe ?

I don't understand what you mean by Opaque Pointer, and there are a few different ways to get to a GTRepository, some which might not be well-supported (usinggit_repository_new() is the one I'd be surprised would work, or some edge-cases of git_submodule_open). The others should be okay. I just want to clarify if you're only going through Objective-C or if you're somehow customizing something.

@arguiot
Copy link
Author

arguiot commented May 22, 2019

The OpaquePointer I’m talking about is created by SwiftGit2, a small git library for Swift.
My project is written in Swift, but I’m able to use Objective Git, as Swift runs on the ObjC runtime.

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 a pull request may close this issue.

2 participants