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

Segfault-on-exit due to lazy LibGit2 initialization #28306

Closed
timholy opened this issue Jul 27, 2018 · 4 comments · Fixed by #29121
Closed

Segfault-on-exit due to lazy LibGit2 initialization #28306

timholy opened this issue Jul 27, 2018 · 4 comments · Fixed by #29121
Labels
libgit2 The libgit2 library or the LibGit2 stdlib module regression Regression in behavior compared to a previous version

Comments

@timholy
Copy link
Member

timholy commented Jul 27, 2018

#28113 reduced loading times (yay!) by lazy-initialization of libgit2, however, now certain Revise tests lead to a segfault when Julia is exited. Here's a small reproducer:

julia> import LibGit2

julia> path = dirname(dirname(Sys.BINDIR))
"/home/tim/src/julia-1.0"

julia> repo = LibGit2.GitRepo(path)
LibGit2.GitRepo("/home/tim/src/julia-1.0")

julia> status = LibGit2.GitStatus(repo;
                                  status_opts=LibGit2.StatusOptions(flags=LibGit2.Consts.STATUS_OPT_INCLUDE_UNMODIFIED))
LibGit2.GitStatus(LibGit2.GitRepo("/home/tim/src/julia-1.0"), Ptr{Nothing} @0x0000555b2d20e0f0)

julia> exit()

signal (11): Segmentation fault
in expression starting at no file:0
git_strmap_lookup_index at /home/tim/src/julia-1.0/usr/bin/../lib/libgit2.so (unknown line)
unknown function (ip: 0x1)
Allocations: 11218380 (Pool: 11216399; Big: 1981); GC: 24
Segmentation fault (core dumped)

You can avoid the segfault by adding

julia> status = repo = 0

julia> GC.gc()

before exit(), so it seems likely to be a resource-cleanup issue.

This segfault does not happen if you revert c670f1a.

@ararslan ararslan added regression Regression in behavior compared to a previous version libgit2 The libgit2 library or the LibGit2 stdlib module labels Jul 27, 2018
timholy added a commit to timholy/Revise.jl that referenced this issue Jul 27, 2018
Work-around for JuliaLang/julia#28306
This can be reverted once that is fixed.
timholy added a commit to timholy/Revise.jl that referenced this issue Jul 27, 2018
Work-around for JuliaLang/julia#28306
This can be reverted once that is fixed.
jbrea added a commit to JuliaReinforcementLearning/ArcadeLearningEnvironment.jl that referenced this issue Aug 14, 2018
Closes #2; see [here](JuliaLang/julia#28306).
@bjarthur
Copy link
Contributor

bjarthur commented Sep 3, 2018

thanks for the hack around @timholy !

@timholy
Copy link
Member Author

timholy commented Sep 3, 2018

@StefanKarpinski, since this was caused by #28113, any chance this is on your radar?

@StefanKarpinski
Copy link
Member

No idea, but is it possible that this uncovers some use case whereby the libgit2 initialization doesn't happen before usage? It's possible I missed something when making the initialization lazy.

@timholy
Copy link
Member Author

timholy commented Sep 10, 2018

From the symptoms, I'm guessing it's more about the order in which various resources get shut down or something. But I haven't poked at this, so take it for what it's worth::Nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libgit2 The libgit2 library or the LibGit2 stdlib module regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants