Cred type finalization can cause SIGSEGV
#553
Labels
No Label
bug
duplicate
enhancement
invalid
question
up for grabs
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: jcarr/git2go#553
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi there,
In using the library I was able to cause a panic in the go runtime. It appears as though a Cred is being freed twice. It appears as though when you use a cred for ssh, libgit2 cleans up the cred that it creates, for example see
172239021f/src/transports/ssh.c (L684-L685)
. However, git.Cred structs have a finalizer attached to them by defaulta32375a860/credentials.go (L28-L32)
.On my machine, this exhibits the behaviour I am describing.
huh, I think i have not seen this before since the fork i have been using in production uses a Golang implementation of SSH
aafbf47bbf
but we still need to be able to distinguish between instances that come from within libgit2 and instances that are allocated from Go and set the finalizer accordingly.
thanks for reporting this!
same for plaintext creds. @lhchavez, what do you mean by 'distinguish between instances that come from within libgit2 and instances that are allocated from Go' what are the cases when the finalizer is actually needed?
3a2102638d/remote.go (L249)
the ownership of
cred
allocated above will be transferred to libgit on this line3a2102638d/remote.go (L257)
and libgit will eventually free it. But the finalizer forcred
will do the same. And actually, the finalizer can do it even earlier as from go perspective,cred
is already garbage after L257@lhchavez and a follow up question - what memory leaks you were trying to fix in https://github.com/libgit2/git2go/pull/478? Thanks.
if git2go uses a manged transport (like in
aafbf47bbf
, where libgit2's ssh implementation is not involved, which by the way needs to be upstreamed at some point), there's nobody that frees theCred
object, and you get a leak.