Skip to content

GTRepository dealloc crash #689

Description

@arguiot

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)

Activity

  1. arguiot commented on May 16, 2019

    @arguiot
    Author

    Actually, I sent a PR: #690

  2. tiennou commented on May 20, 2019

    @tiennou
    Contributor

    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.

  3. arguiot commented on May 22, 2019

    @arguiot
    Author

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

  4. tiennou commented on May 22, 2019

    @tiennou
    Contributor

    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.

  5. arguiot commented on May 22, 2019

    @arguiot
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions