Julia: Intermittent libgit2 test segfault

Created on 29 Apr 2017  路  4Comments  路  Source: JuliaLang/julia

Can be reproduced on current master on 64 bit linux by running make test-libgit2 a bunch of times in a row. Looks like

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
git_config_free at /home/tkelman2/Julia/julia-0.6/usr/bin/../lib/libgit2.so (unknown line)
close at ./libgit2/types.jl:547
unknown function (ip: 0x2b3d1e01712a)
jl_call_fptr_internal at /home/tkelman2/Julia/julia-0.6/src/julia_internal.h:337 [inlined]
jl_call_method_internal at /home/tkelman2/Julia/julia-0.6/src/julia_internal.h:356 [inlined]
jl_apply_generic at /home/tkelman2/Julia/julia-0.6/src/gf.c:1930
jl_apply at /home/tkelman2/Julia/julia-0.6/src/julia.h:1422 [inlined]
run_finalizer at /home/tkelman2/Julia/julia-0.6/src/gc.c:111
jl_gc_run_finalizers_in_list at /home/tkelman2/Julia/julia-0.6/src/gc.c:200
run_finalizers at /home/tkelman2/Julia/julia-0.6/src/gc.c:234
jl_atexit_hook at /home/tkelman2/Julia/julia-0.6/src/init.c:265
main at /home/tkelman2/Julia/julia-0.6/ui/repl.c:265
__libc_start_main at /build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:287
unknown function (ip: 0x4015fa)
Allocations: 9425217 (Pool: 9416101; Big: 9116); GC: 13
Segmentation fault
make[1]: *** [libgit2] Error 139
make: *** [test-libgit2] Error 2

Not sure yet whether this was introduced by #21603 or #21597. 36b056e547344ad3f4828067b174a240ecbb7475 can reproduce the problem, and at 991b581c2723c57fc0d5005c1c7b61a1b0458308 I can run make test-libgit2 40 times in a row with no problems. Still testing at the commits between there.

bug libgit2 upstream

All 4 comments

Caught in rr locally, will have a breif look....

Currently reduced to

mktempdir() do dir
    # test parameters
    cache_repo = joinpath(dir, "Example")

    repo = LibGit2.init(cache_repo)
    close(repo)

    up_path = joinpath(dir, "Example.PushUp")
    up_repo = LibGit2.clone(cache_repo, up_path)
    our_path = joinpath(dir, "Example.Push")
    our_repo = LibGit2.clone(cache_repo, our_path) # 0->1
    # need to set this for merges to succeed
    global our_cfg = LibGit2.GitConfig(our_repo) # 1->2
    LibGit2.set!(our_cfg, "user.name", "AAAA")
    LibGit2.set!(our_cfg, "user.email", "[email protected]")
    global up_cfg = LibGit2.GitConfig(up_repo)
    LibGit2.set!(up_cfg, "user.name", "AAAA")
    LibGit2.set!(up_cfg, "user.email", "[email protected]")
    try
        open(joinpath(LibGit2.path(our_repo),"file1"),"w") do f
            write(f, "111\n")
        end
        LibGit2.add!(our_repo, "file1")
        LibGit2.commit(our_repo, "add file1")
        # we cannot yet locally push to non-bare repos
        try
            LibGit2.push(our_repo, remoteurl=up_path) # 2->1
        end
    finally
        close(our_repo) # 1->0
        close(up_repo)
    end
end
ccall(:jl_, Void, (Any,), our_cfg)
close(our_cfg)

Note the comment about the refcount on our_cfg. Somehow the LibGit2.push(our_repo, remoteurl=up_path) decreases the refcount on the config

This is an upstream bug. Ref https://github.com/libgit2/libgit2/pull/4224. I'll push the fix to https://github.com/JuliaLang/julia/pull/21636 to reduce conflicts. Also, this get's triggered on travis on that PR .... https://travis-ci.org/JuliaLang/julia/jobs/227153347

This might also explain some of the hangs on the CI since the double free corrupts libc internal datastructure causing random error when printing error messages....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanKarpinski picture StefanKarpinski  路  3Comments

iamed2 picture iamed2  路  3Comments

ararslan picture ararslan  路  3Comments

m-j-w picture m-j-w  路  3Comments

wilburtownsend picture wilburtownsend  路  3Comments