unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Magali <magalilemes00@gmail.com>
Cc: Guix Devel <guix-devel@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>
Subject: Re: [outreachy] Walk through the Git history (guix git {authenticate,log})
Date: Fri, 18 Dec 2020 16:34:57 +0100	[thread overview]
Message-ID: <87sg839lge.fsf@gnu.org> (raw)
In-Reply-To: <c333cabd-dbe4-9718-56e8-64e03ee1024d@gmail.com> (Magali's message of "Tue, 15 Dec 2020 12:20:09 -0300")

Hi Magali,

Magali <magalilemes00@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?

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.

Hope this helps!

Ludo’.


  parent reply	other threads:[~2020-12-18 15:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 17:41 [outreachy] Walk through the Git history (guix git {authenticate, log}) zimoun
2020-12-11 19:01 ` [outreachy] Walk through the Git history (guix git {authenticate,log}) Magali
2020-12-12 12:24   ` zimoun
2020-12-12 17:24     ` Magali
2020-12-12 17:49       ` [outreachy] Walk through the Git history zimoun
2020-12-14 10:20         ` Ludovic Courtès
2020-12-15 15:20     ` [outreachy] Walk through the Git history (guix git {authenticate,log}) Magali
2020-12-16  9:35       ` zimoun
2020-12-18 15:34       ` Ludovic Courtès [this message]
2020-12-19  3:18         ` Magali
2020-12-12  8:42 ` Mathieu Othacehe
2020-12-12 12:10   ` zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sg839lge.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=magalilemes00@gmail.com \
    --cc=othacehe@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).