{"action":"created","issue":{"url":"https://api.github.com/repos/nodegit/nodegit/issues/630","labels_url":"https://api.github.com/repos/nodegit/nodegit/issues/630/labels{/name}","comments_url":"https://api.github.com/repos/nodegit/nodegit/issues/630/comments","events_url":"https://api.github.com/repos/nodegit/nodegit/issues/630/events","html_url":"https://github.com/nodegit/nodegit/issues/630","id":91629672,"number":630,"title":"Bug when cloning two repos and one repo doesn't exist","user":{"login":"Spidy88","id":1076168,"avatar_url":"https://avatars.githubusercontent.com/u/1076168?v=3","gravatar_id":"","url":"https://api.github.com/users/Spidy88","html_url":"https://github.com/Spidy88","followers_url":"https://api.github.com/users/Spidy88/followers","following_url":"https://api.github.com/users/Spidy88/following{/other_user}","gists_url":"https://api.github.com/users/Spidy88/gists{/gist_id}","starred_url":"https://api.github.com/users/Spidy88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spidy88/subscriptions","organizations_url":"https://api.github.com/users/Spidy88/orgs","repos_url":"https://api.github.com/users/Spidy88/repos","events_url":"https://api.github.com/users/Spidy88/events{/privacy}","received_events_url":"https://api.github.com/users/Spidy88/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-28T19:27:49Z","updated_at":"2015-06-28T20:57:20Z","closed_at":null,"body":"When I try to clone two repos at the same time, I'm getting inconsistent behavior. Sometimes it works, sometimes it breaks with some very odd error messages. The first repo exists on Github. The second repo does not. When I run the program multiple times (and the local folders are removed each time) I've gotten the following behaviors:\r\n\r\n1. Program freezes, creating both directories with .git file/folders and nothing else\r\n2. Program fails with `Segmentation fault: 11`\r\n3. Program clones first directory successfully, second fails but with wrong error message (`authentication required but no callback set`)\r\n4. Program fails with ```node(33647,0x103a0a000) malloc: *** error for object 0x102802540: double free\r\n*** set a breakpoint in malloc_error_break to debug\r\nAbort trap: 6```\r\n\r\nThese errors happened in exactly this order as well when I continued to run the program. Code attached below for help recreating.\r\n\r\n```\r\nvar path = require('path');\r\nvar git = require('nodegit');\r\nvar tmp = require('tmp');\r\nvar Promise = require('bluebird');\r\n\r\nvar CLONE_OPTIONS = {\r\n    remoteCallbacks: {\r\n        certificateCheck: function() { return 1; },\r\n        credentials: function (url, username) {\r\n            return git.Cred.sshKeyFromAgent(username);\r\n        }\r\n    }\r\n};\r\n\r\nvar upstreamPromise = cloneRepository('some-private-org', 'awesome-repo', path.join(__dirname, '/private-repo'))\r\n    .then(repoCloneSuccess, repoCloneFailure);\r\n\r\nvar downstreamPromise = cloneRepository('Spidy88', 'forked-private-repo', path.join(__dirname, '/forked-private-repo'))\r\n    .then(repoCloneSuccess, repoCloneFailure);\r\n\r\nPromise.all([upstreamPromise, downstreamPromise])\r\n    .spread(\r\n        function(upstream, downstream) {\r\n            console.log('Upstream: ', upstream && upstream.path());\r\n            console.log('Downstream: ', downstream && downstream.path());\r\n        },\r\n        function(upstreamReason, downstreamReason) {\r\n            console.log('Upstream failed: ', upstreamReason);\r\n            console.log('Downstream failed: ', downstreamReason);\r\n        }\r\n    );\r\n\r\nfunction cloneRepository(ownerName, repoName, outputPath) {\r\n    var repoUrl = 'git@github.com:' + ownerName + '/' + repoName + '.git';\r\n    return git.Clone(repoUrl, outputPath, CLONE_OPTIONS);\r\n}\r\n\r\nfunction repoCloneSuccess(repository) {\r\n    console.log('Clone success');\r\n    console.log(\"Is the repository bare? %s\", Boolean(repository.isBare()));\r\n    return repository;\r\n}\r\n\r\nfunction repoCloneFailure(reason) {\r\n    console.log('Clone failed: ', reason);\r\n    return reason;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/nodegit/nodegit/issues/comments/116333509","html_url":"https://github.com/nodegit/nodegit/issues/630#issuecomment-116333509","issue_url":"https://api.github.com/repos/nodegit/nodegit/issues/630","id":116333509,"user":{"login":"Spidy88","id":1076168,"avatar_url":"https://avatars.githubusercontent.com/u/1076168?v=3","gravatar_id":"","url":"https://api.github.com/users/Spidy88","html_url":"https://github.com/Spidy88","followers_url":"https://api.github.com/users/Spidy88/followers","following_url":"https://api.github.com/users/Spidy88/following{/other_user}","gists_url":"https://api.github.com/users/Spidy88/gists{/gist_id}","starred_url":"https://api.github.com/users/Spidy88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Spidy88/subscriptions","organizations_url":"https://api.github.com/users/Spidy88/orgs","repos_url":"https://api.github.com/users/Spidy88/repos","events_url":"https://api.github.com/users/Spidy88/events{/privacy}","received_events_url":"https://api.github.com/users/Spidy88/received_events","type":"User","site_admin":false},"created_at":"2015-06-28T20:57:20Z","updated_at":"2015-06-28T20:57:20Z","body":"The verified solution so far is to run the first clone, and when it completes, run the second clone. Not optimal for complex applications but hopefully this helps narrow down the bug. Threading issue maybe?"}}