-
Notifications
You must be signed in to change notification settings - Fork 318
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
Allow use of libgit2 built without thread support #918
Conversation
git.go
Outdated
// Due to the multithreaded nature of Go and its interaction with | ||
// calling C functions, we cannot work with a library that was not built | ||
// with multi-threading support. The most likely outcome is a segfault | ||
// or panic at an incomprehensible time, so let's make it easy by | ||
// panicking right here. | ||
if features&FeatureThreads == 0 { | ||
panic("libgit2 was not built with threading support") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we can really remove this unless we make something that forces git2go calls to be in the same OS thread (or add a huge mutex lock surrounding every CGO call).
at least not in general. some applications might be totally fine with this. but this is a library, and needs to support that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lhchavez thank you for the quick reply. The main issue we have is that this validation happens at init()
, which blocks downstream projects from going around it without forking git2go
.
Would you be able to recommend any other approach in which we could fix #917 instead? We have been investigating user reports for about 3 months, as it was quite difficult to get to the right conditions to reproduce, so we would really appreciate any other recommendations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lhchavez would it be possible to add an env variable or a global variable to bypass this check? The default behavior would still be to run the check and panic, if required. But for projects, which would like to use libgit2
without multithreading support, it'd be nice to have a way of disabling this panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I amended the PR accordingly, please take another look.
With smart transport, users using solely Managed Transports can rely on Go to deal with the multi-threading requirements of transport management. To enable threadless libgit2 an environment variable ALLOW_THREADLESS_LIBGIT2 must be set to true. As long as the git2go objects are not being shared across Go routines this arrangement seems to work well. By leveraging this and the removal of unmanaged transport we have experienced a decrease in segfaults or random errors when using git2go for accessing multiple Git repositories concurrently. Fixes #917. Signed-off-by: Paulo Gomes <[email protected]>
Allow use of libgit2 built without thread support.
With smart transport, users using solely Managed Transports can rely on Go to deal with the multi-threading requirements of transport management.
To enable threadless libgit2 an environment variable
ALLOW_THREADLESS_LIBGIT2
must be set totrue
.As long as the git2go objects are not being shared across Go routines this arrangement seems to work well.
By leveraging this and the removal of unmanaged transport we have experienced a decrease in segfaults or random errors when using git2go for accessing multiple Git repositories concurrently.
Fixes #917.