Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Libgit2 Segfault #24625

@JaredCrean2

Description

@JaredCrean2

Symptoms

On julia 0.6.1 it appears libgit2 builds incorrectly on older Debian system.

After modifying/deps/libgit2.mk to set -DBUILD_CLAR=ON (so the libgit2 tests will be built) and building julia, running the libgit2 tests segfaults part way through. This happens on Debian 6, but not Debian 7.

Also on Debian 6, launching julia gives the message:

fatal: error thrown and no exception handler available.
Base.InitError(mod=:LibGit2, error=ErrorException("error initializing LibGit2 module"))
rec_backtrace at /home/dev/julia/src/stackwalk.c:84
record_backtrace at /home/dev/julia/src/task.c:245
jl_throw at /home/dev/julia/src/task.c:564
__init__ at ./libgit2/libgit2.jl:920
unknown function (ip: 0x7f9469e06ad8)
jl_call_fptr_internal at /home/dev/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/dev/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/dev/julia/src/gf.c:1926
jl_apply at /home/dev/julia/src/julia.h:1424 [inlined]
jl_module_run_initializer at /home/dev/julia/src/toplevel.c:87
_julia_init at /home/dev/julia/src/init.c:733
julia_init at /home/dev/julia/src/task.c:297
main at /home/dev/julia/ui/repl.c:259
__libc_start_main at /lib/libc.so.6 (unknown line)
unknown function (ip: 0x401698)

but on Debian 7 julia launches normally. Because the tests segfault and the SSL certificates are installed in the same place in both cases, I think this is different than #18693. Also, setting the environmental variables described in that issue did not help.

Building libgit2 separately from julia and linking it to OpenSSL 1.0.2m (the system OpenSSL is too old) works (on Debian 6). It appears the problem is specific to how julia is building libgit2.

Steps to reproduce

Using a virtual machine (preferably with multiple cores, to speed up step 4)

  1. Install Debian 6 (installation medium here). During installation, decline to use a network mirror (Debian 6 packages are no longer available on the regular mirrors)

  2. Download the scripts here to your home directory

  3. Run install_pkgs.sh as root. This will update apt to find the archive mirror and install as many dependencies from there as possible.

  4. Run install_src.sh as a regular user. This will build all remaining dependencies from source and then build julia itself. This takes a while because GCC, CMake, Binutils, and Python 2.7 have to be built. They will be installed to ~/local. Make sure to source ~/.bashrc after this script completes.

  5. Now you can attempt to launch julia (in $HOME/julia) to verify it does not work. You can then go into ~/julia/deps/scratch/libgit2-COMMIT_HASH) and run libgit2_clar to see it segfault.

There is also a script install_ssl.sh to install OpenSSL 1.0.2m to ~/crypto and updates .bashrc. It is not run as part of step 4 but may be useful for debugging.

Backtrace

Running libgit2_clar under gdb gives this backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004919fc in git_mwindow_get_pack ()
(gdb) backtrace
#0  0x00000000004919fc in git_mwindow_get_pack ()
#1  0x000000000043709e in packfile_load(char, bool) ()
#2  0x0000000000478624 in git_path_direach ()
#3  0x0000000000436f0f in pack_backend__refresh ()
#4  0x0000000000437bd4 in git_odb_backend_pack ()
#5  0x000000000041c98c in add_default_backends ()
#6  0x000000000041d65f in git_odb_open ()
#7  0x00000000004322ab in git_repository_odb__weakptr ()
#8  0x000000000046a1e2 in git_object_lookup_prefix ()
#9  0x000000000041280e in git_attr_file__load ()
#10 0x0000000000424994 in git_attr_cache__get ()
#11 0x000000000041fcc6 in collect_attr_files ()
#12 0x000000000041ff90 in git_attr_get ()
#13 0x00000000005f40da in test_attr_flags__index_vs_workdir ()
#14 0x00000000004cd583 in clar_run_test.isra.6 ()
#15 0x00000000004cda41 in clar_test_run ()
#16 0x000000000040f46a in main ()

Also, ldd confirms libgit2.so linked to mbedtls built by julia and not the system OpenSSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libgit2The libgit2 library or the LibGit2 stdlib module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions