Hi! On 18/12/2020 12:34, Ludovic Courtès wrote: > Hi Magali, > > Magali <magalileme...@gmail.com> skribis: > >> scheme@(guix-user)> (let* ((repo (repository-open cache)) >> (latest-commit >> (commit-lookup repo (reference-target (repository-head repo))))) >> (let loop ((commit latest-commit) >> (res (list latest-commit))) >> (match (commit-parents commit) >> (() (reverse res)) >> ((head . tail) >> (loop head (cons head res)))))) >> Segmentation fault (core dumped) > I can reproduce the bug; the C backtrace looks like this: > > --8<---------------cut here---------------start------------->8--- > (gdb) bt > #0 0x00007fabfa9d31ee in git_oidmap_get () > from > /gnu/store/zchrrs2zf4l06cszbadqsk18329q78sg-libgit2-1.1.0/lib/libgit2.so > #1 0x00007fabfa98d516 in cache_get () from > /gnu/store/zchrrs2zf4l06cszbadqsk18329q78sg-libgit2-1.1.0/lib/libgit2.so > #2 0x00007fabfa9cbef7 in git_object_lookup_prefix () > from > /gnu/store/zchrrs2zf4l06cszbadqsk18329q78sg-libgit2-1.1.0/lib/libgit2.so > #3 0x00007fac01b8866d in ffi_call_unix64 () > from /gnu/store/bw15z9kh9c65ycc2vbhl2izwfwfva7p1-libffi-3.3/lib/libffi.so.7 > #4 0x00007fac01b86ac0 in ffi_call_int () from > /gnu/store/bw15z9kh9c65ycc2vbhl2izwfwfva7p1-libffi-3.3/lib/libffi.so.7 > #5 0x00007fac01e54f2e in scm_i_foreign_call (cif_scm=<optimized out>, > pointer_scm=<optimized out>, > errno_ret=errno_ret@entry=0x7ffe5fc1f95c, argv=0x7fabfe2e4980) at > foreign.c:1073 > #6 0x00007fac01ec3a84 in foreign_call (thread=0x7fac014a8d80, cif=<optimized > out>, pointer=<optimized out>) > at vm.c:1282 > --8<---------------cut here---------------end--------------->8--- > > Could it be that, if you keep ‘repo’ in a global variable like in the > example zimoun posted, segfault no longer occurs?
Yes, this seems to work just fine. > I believe that what happens is a bug in Guile-Git: ‘repo’ is “finalized” > (freed) before Guile inspects the commit objects to print them, and when > Guile gets around to printing those commit objects, they now refer to a > repo that has been freed, hence the crash. > > Until the bug is fixed, the workaround is to arrange your code so that > the repository object outlives commit objects. We can discuss this > further here or on IRC if you want. Nice! Thanks. > Hope this helps! It sure did :-) Magali