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

Bump libgit2 to v0.28.2 and backport some fixes #804

Merged
merged 4 commits into from Jun 18, 2019

Conversation

carlosmn
Copy link
Member

It includes a couple of leaks in case of error and a warning fix which could make you fail to compile if you have strict mode.

carlosmn and others added 4 commits June 18, 2019 13:25
When we call the block, an exception or even a call to `break` would cause us to
unwind the stack and skip any resource freeing that we may have. The solution is
to call `rb_protect` which will let us catch the exception and raise whenever we
need to.

Doing this as part of a `git_status_foreach` is unnecessarily awkward so move to
iterating over the status list ourselves and free the entry list as soon as we
notice there was an exception.

For example, this program will consume memory
indefinitely:

    require 'rugged'

    repo = Rugged::Repository.new ARGV[0]
    loop do
      repo.status do |file, status_data|
        break
      end
    end

Thanks to Aaron Patterson for discovering this and the original hacky fix.
Not doing so means an exception or even a break will jump over us and not give
us the opportunity to free the resources we've allocated.
I use strict compiler flags on my version of Ruby.  Since the callback
signature didn't match correctly, compilation would fail.  This fixes
the nogvl callback signature.
@carlosmn carlosmn merged commit 663bcc0 into maint/v0.28 Jun 18, 2019
@carlosmn carlosmn deleted the cmn/bump-libit2-28 branch June 18, 2019 12:18
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.

None yet

2 participants