all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe@gmail.com>
Cc: guix-devel <guix-devel@gnu.org>, Amirouche <amirouche@hypermove.net>
Subject: Re: (guix git) and guile-git finalizers.
Date: Tue, 13 Jun 2017 10:15:52 +0200	[thread overview]
Message-ID: <87zidc2thj.fsf@gnu.org> (raw)
In-Reply-To: <86h8zliddr.fsf@gmail.com> (Mathieu Othacehe's message of "Mon, 12 Jun 2017 14:44:48 +0200")

Hi!

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> While integrating (guix git) into Cuirass, I noticed unexpected
> segfaults during "latest-repository-commit" evaluation.
>
> Segfaults can be narrowed to the following lines:
>
> (use-modules (git))
> (begin (libgit2-init!)
>        (let ((rep (repository-open "some-git-repo")))
>          (remote-fetch (remote-lookup rep "origin")))
>        (libgit2-shutdown))
>
>
> Note that, it's not 100% reproducible, but re-executing 4 or 5 times the
> above snippet is often enough to observe the segfault.
>
> Here's the gdb backtrace I collected :
>
> #0  0x00007fffef7eb181 in git_mwindow_put_pack () from /gnu/store/ilaffvq27kfy2la235hddkxcalj9r
> #1  0x00007fffef7f2897 in pack_backend(float, long double,...)(...) () from /gnu/store/ilaffvq2
> #2  0x00007fffef7eef72 in git_odb_free () from /gnu/store/ilaffvq27kfy2la235hddkxcalj9r2i7-libg
> #3  0x00007fffef8134ce in git_repository.cleanup () from /gnu/store/ilaffvq27kfy2la235hddkxcalj
> #4  0x00007fffef81351a in git_repository_free () from /gnu/store/ilaffvq27kfy2la235hddkxcalj9r2
> #5  0x00007ffff7b01e37 in chained_finalizer () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs
> #6  0x00007ffff785170f in GC_invoke_finalizers () from /gnu/store/j4p7cnxb6byf1wra3yz6pk8av4g5m
> #7  0x00007ffff7b02099 in scm_run_finalizers () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dx
> #8  0x00007ffff7b020f5 in finalization_thread_proc () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k
> #9  0x00007ffff7af2cba in c_body () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-guile-2.2.
> #10 0x00007ffff7b680c9 in vm_debug_engine () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-g
> #11 0x00007ffff7b752aa in scm_call_n () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-guile-
> #12 0x00007ffff7b644e6 in catch () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-guile-2.2.2
> #13 0x00007ffff7af32a0 in scm_i_with_continuation_barrier () from /gnu/store/5zx29y44nrqj0s8h3j
> #14 0x00007ffff7af3335 in scm_c_with_continuation_barrier () from /gnu/store/5zx29y44nrqj0s8h3j
> #15 0x00007ffff7b6310c in with_guile () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-guile-
> #16 0x00007ffff7858732 in GC_call_with_stack_base () from /gnu/store/j4p7cnxb6byf1wra3yz6pk8av4
> #17 0x00007ffff7b63498 in scm_with_guile () from /gnu/store/5zx29y44nrqj0s8h3jlvlj82k8hj4dxs-gu
> #18 0x00007ffff7625454 in start_thread () from /gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glib
> #19 0x00007ffff5fed7bf in clone () from /gnu/store/rmjlycdgiq8pfy5hfi42qhw3k7p6kdav-glibc-2.25/
>
> I supposed that what happends is the following race-condition :
> * (libgit2-shutdown) is called
> * the finalizer %repository-free is called in an other thread.
> * because shutdown has already been called the finalizer fails and
> segfaults.

Could be!

I think using ‘libgit2-shutdown’ is risky because as you can see it can
be tricky to implement it correctly.  So my first recommendation would
be to not try to use it.  :-)  Guile cannot really unload modules ATM
anyway.

To fix this, I think ‘libgit2-shutdown’ needs to call
‘scm_run_finalizers’ before calling ‘git_shutdown’, but I’m not sure if
it’s enough.

HTH,
Ludo’.

  reply	other threads:[~2017-06-13  8:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-12 12:44 (guix git) and guile-git finalizers Mathieu Othacehe
2017-06-13  8:15 ` Ludovic Courtès [this message]
2017-06-13 16:41   ` Mathieu Othacehe
2017-06-19 16:01   ` Mathieu Othacehe
2017-06-22 11:40     ` Andy Wingo
2017-07-01 10:16       ` Mathieu Othacehe
2017-07-01 12:50         ` Ludovic Courtès
2017-07-01 14:33           ` Mathieu Othacehe
2017-06-13  8:47 ` Andy Wingo
2017-06-13 16:39   ` Mathieu Othacehe

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

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

  git send-email \
    --in-reply-to=87zidc2thj.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=amirouche@hypermove.net \
    --cc=guix-devel@gnu.org \
    --cc=m.othacehe@gmail.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.