Skip to content

Lookup a non existent commit crashes the process. #353

Closed

Description

@addisonj

I am doing some analysis of a codebase over time using nodegit, I am getting commits from an outside source that may no longer exist.

Doing Commit.lookup says it should be safe, but if I do a lookup with an invalid commit (but a full sha), I get the following error:

good repo
[Error: Object not found - failed to find pack entry (b5e13cc50f98d9a045bebadffacf396b9ee49ad5)]
node(16924,0x7fff73d77300) malloc: *** error for object 0x100d02be0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Here is some example code that causes the failure:

var nodegit = require("nodegit")
var Repo = nodegit.Repository
var Commit = nodegit.Commit

Repo.open("/path/to/myrepo").then(function(repo) {
  console.log("good repo")
  // missing, but valid full length, sha
  return Commit.lookup(repo, "b5e13cc50f98d9a045bebadffacf396b9ee49ad5").then(function(commit) {
    console.log(commit.message())
  }, function(err) { console.log(err); throw err})
}, function(err) { console.log(err); throw err })

Activity

  1. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    Using the example code that you provided I'm unable to get the malloc error. I do stil get the object not found error which is correct and to be expected.

    Is there something I'm missing in your test case to get the malloc error?

  2. addisonj commented on Jan 15, 2015

    @addisonj
    Author

    hrm... odd.

    If I use an invalid sha format (too short, etc) I get the error but no malloc error.

    Here is a more precise example against the nodegit repo itself. I copied this code and dropped it into the root of nodegit on latest master. Still get the same error.

    var nodegit = require("./")
    var Repo = nodegit.Repository
    var Commit = nodegit.Commit
    
    Repo.open(process.cwd()).then(function(repo) {
      console.log("good repo")
      return Commit.lookup(repo, "81c51dba7ffbecb6a6257398f5ad3ad9be775c8c").then(function(commit) {
        console.log(commit.message())
      }, function(err) { console.log(err); throw err})
    }, function(err) { console.log(err); throw err })

    I wonder if it might be OS issue? I am running OSX Yosemite

  3. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    Running that code in the root of nodegit on the master branch I still can't get a malloc.

    I'm on OSX Yosemite as well. What version of node are you running?

  4. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    Damn, unable to repo on either v0.10.33 or v0.11.14 of node.

  5. addisonj commented on Jan 15, 2015

    @addisonj
    Author

    v0.10.35

  6. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    Updated to v0.10.35 and still no dice. I think I know the issue though. Can you checkout #354 and see if that fixes your problem?

  7. addisonj commented on Jan 15, 2015

    @addisonj
    Author

    okay, first, thanks so much for being so responsive.

    I didn't realize that you have a pre-built binary. It took me a bit to figure out how to rebuild. When I use the pre-built it fails, but when I build my own, from master or the branch in #354 they both work properly.

    Not sure where it leaves this, but let me know if I can do anything further to help.

  8. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    Oh ok. We must have fixed that in master then. I'll reject that PR and when we version bump you should be good. libgit2 released 0.21.4 so we should be version bumping here pretty soon.

  9. addisonj commented on Jan 15, 2015

    @addisonj
    Author

    Sorry for the confusion. Once again, really appreciate the help!

    On Thu Jan 15 2015 at 4:40:01 PM John Haley notifications@github.com
    wrote:

    Closed #353 #353.

    —
    Reply to this email directly or view it on GitHub
    #353 (comment).

  10. johnhaley81 commented on Jan 15, 2015

    @johnhaley81
    Collaborator

    No worries! Always glad to help :)

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