Skip to content

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

@timholy

Description

@timholy

#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libgit2The libgit2 library or the LibGit2 stdlib moduleregressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions