unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Patrick Totzke <patricktotzke@gmail.com>
To: Floris Bruynooghe <flub@devork.be>, notmuch@notmuchmail.org
Subject: Re: notmuch2 (python cffi bindings) segfault gdb logs
Date: Wed, 25 Nov 2020 10:35:27 +0000	[thread overview]
Message-ID: <160630052747.135120.6464979361290025771@piu> (raw)
In-Reply-To: <871rgiqw6j.fsf@powell.devork.be>

Hello Floris, thanks for having a look at this!


Quoting Floris Bruynooghe (2020-11-24 21:31:00)

> Hi Patrick,
> 
> On Mon 23 Nov 2020 at 10:36 +0000, Patrick Totzke wrote:
> > I've been complaining about the new (and old) python bindings causing the python interpreter to segfault occasionally. So far I was not able to reproduce this reliably nor provide error traces. This has just changed:
> > see below and attached for what I got from gdb.
> 
> Your gdb info doesn't say explicitly (or I missed it), but this is
> showing a SEGFAULT I guess?

Yes, correct. I saw this triggered when untagging some messages from my inbox in alot.
I forgot to mention version numbers: 

    notmuch: 0.31+7~g981d5a0
    Python: 3.8.6
    alot: 0.9.1

notmuch and bindings are compiled from git master, on a debian testing system.


> > I hope that whoever is in charge of the bindings can make sense of
> > it. I don't have any experience so far with cffi nor gdb and have a
> > hard time debugging this. The logs below are my attempt to collect as
> > much detail as possible about. Please let me know if I missed
> > something.
> 
> From what I can tell we're calling a function to free something which
> segfaults, so it probably was freed already and we didn't know.  We need
> to find out who freed it before and why we thought it still needed to be
> freed.
 

It may help to know that this only ever happened if i tagged messages while the alot screen did not display the whole query result.
I presume that this means there was some left over reference to an existing query object, which could have been affected by libtalloc.

Alot is reading thread id's from notmuch2.Database.threads() in a generator:
https://github.com/pazz/alot/blob/master/alot/db/manager.py#L314
Could this be problematic? After all, it may continue reading from it after a while.


> > (gdb) info threads
> >   Id   Target Id                                     Frame 
> > * 1    Thread 0x7ffff7c0e740 (LWP 3614451) "python3" __GI_raise (sig=sig@entry=6)
> >     at ../sysdeps/unix/sysv/linux/raise.c:50
> 
> From this I gather we only have one thread, could you confirm this?
> notmuch2 just isn't thread safe at the moment (I forget whether this was
> intentional or by accident, might have been intentional depending on how
> threadsafe libnotmuch is).


Yes, I'm quite -- but not 100% --- sure as I did not write the port to notmuch2 for alot's backend.


> > Traceback (most recent call first):
> >   <built-in method notmuch_thread_destroy of CompiledLib object at remote 0x7ffff636f040>
> >   File "/home/pazz/.local/lib/python3.8/site-packages/notmuch2/_thread.py", line 38, in _destroy
> >     capi.lib.notmuch_thread_destroy(self._thread_p)
> >   File "/home/pazz/.local/lib/python3.8/site-packages/notmuch2/_thread.py", line 34, in __del__
> >     self._destroy()
> >   File "/home/pazz/projects/alot/alot/db/manager.py", line 570, in get_threads
> >   <built-in method next of module object at remote 0x7ffff78b70e0>
> 
> I pulled alot master and this does not match at all.  Could you tell me
> which git ref this was using so I can try and see what alot is actually
> doing?  (or some other way of sharing the source in this backtrace)


This happed on alot master: 7915ea60ba866010abc728851626df96d8b80816 for me.
I should say that I've had this issue long before, even before alot used the new bindings.

Another stab in the dark: Could this be due to concurrent changes to the notmuch index in my mail sync/tagging script?
I am using afew https://github.com/afewmail/afew which is still on the old python bindings as far as I am aware.

Thanks again for your efforts Floris!
P

      reply	other threads:[~2020-11-25 10:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 10:36 notmuch2 (python cffi bindings) segfault gdb logs Patrick Totzke
2020-11-24 21:31 ` Floris Bruynooghe
2020-11-25 10:35   ` Patrick Totzke [this message]

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://notmuchmail.org/

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

  git send-email \
    --in-reply-to=160630052747.135120.6464979361290025771@piu \
    --to=patricktotzke@gmail.com \
    --cc=flub@devork.be \
    --cc=notmuch@notmuchmail.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://yhetil.org/notmuch.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).