Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The program aborts upon hitting page_down, after toggling tags on an item several times #1504

Open
lenormf opened this issue May 9, 2020 · 12 comments

Comments

@lenormf
Copy link
Contributor

lenormf commented May 9, 2020

I originally thought this issue I'm hitting was #1460, but since the following reproducer is so different from the one in #1460, which I cannot reproduce, I'm reporting details here.

Describe the bug

alot crashes with signal ABORT.

Software Versions

  • Python version: 3.8.2
  • Notmuch version: 0.29.3
  • Alot version: 0.9 (also verified on master, 1e66a3d)

Archlinux.

To Reproduce
Steps to reproduce the behaviour:

  1. open a search buffer, search tag:inbox
  2. hold the s key for ~10s, to mark the same item as read/unread in rapid successions
  3. hit the page-down key

The crash doesn't occur with j or page-up.

But it does occur if you hit ctrl+d twice.

Error Log

alot.log

Full stacktrace, excerpt below:

#0  0x00007ffff7dfcce5 in raise () at /usr/lib/libc.so.6
#1  0x00007ffff7de6857 in abort () at /usr/lib/libc.so.6
#2  0x00007ffff538da20 in talloc_abort () at /usr/lib/libtalloc.so.2
#3  0x00007ffff538da56 in talloc_abort_unknown_value () at /usr/lib/libtalloc.so.2
#4  0x00007ffff538dad4 in talloc_chunk_from_ptr () at /usr/lib/libtalloc.so.2
#5  0x00007ffff538feeb in _talloc_free () at /usr/lib/libtalloc.so.2
#6  0x00007ffff549f5ab in notmuch_thread_destroy () at /usr/lib/libnotmuch.so.5
#7  0x00007ffff61c6c6d in ffi_call_unix64 () at /usr/lib/libffi.so.7
#8  0x00007ffff61c65a7 in ffi_call_int () at /usr/lib/libffi.so.7
#9  0x00007ffff61c6624 in ffi_call () at /usr/lib/libffi.so.7
#10 0x00007ffff621d084 in  () at /usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so

[…]

#82 0x00007ffff7c7881e in Py_RunMain () at /usr/lib/libpython3.8.so.1.0
#83 0x00007ffff7c78909 in Py_BytesMain () at /usr/lib/libpython3.8.so.1.0
#84 0x00007ffff7de8023 in __libc_start_main () at /usr/lib/libc.so.6
#85 0x000055555555505e in _start ()
@lenormf
Copy link
Contributor Author

lenormf commented May 9, 2020

I just reproduced the issue by only hitting s, so I suppose this could be a dupe of #1460 after all. At least we have a fast reproducer here!

@pazz
Copy link
Owner

pazz commented May 9, 2020

Thanks for this. I can reproduce it as initially reported, but not just with the s key.
If you'd take the helm on this one that'd be much appreciated. I don't really have the time to dig deeper into libnotmuch or its bindings. I wasn't even aware that there is a second verison of these bindings.
Is it "official", i.e., part of nochmuch yet?

@lenormf
Copy link
Contributor Author

lenormf commented May 10, 2020

I'll try to look into it, but no promises.

I was actually hoping you could answer those questions, which I asked in #1460 since you commented on the RFC for the FFI bindings.

The bindings were renamed into notmuch2 and are part of the upstream repository - just completely undocumented as far as I could see. There's even a request pending to have a Debian python3-notmuch2 package, to:

encourage new downstream development to rely on notmuch2 instead of on notmuch

@lenormf
Copy link
Contributor Author

lenormf commented May 18, 2020

Got the following output for the first time while using the same reproducer above:

terminate called after throwing an instance of 'Xapian::DatabaseModifiedError'

@lenormf
Copy link
Contributor Author

lenormf commented May 18, 2020

Also got a stacktrace in the debug log, this time!

DEBUG:search:page down
ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:base_events:Task exception was never retrieved
future: <Task finished name='Task-6' coro=<UI._input_filter.<locals>._apply_fire() done, defined at /home/fle/misc/alot/alot/ui.py:193> exception=XapianError()>
Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 195, in _apply_fire
    await self.apply_commandline(cmdline)
  File "/home/fle/misc/alot/alot/ui.py", line 283, in apply_commandline
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read

DEBUG:ui:Got key (['page down'], [27, 91, 54, 126])
DEBUG:ui:cmdline: 'move page down'
DEBUG:ui:search command string: "move page down"
DEBUG:__init__:mode:search got commandline "move page down"
DEBUG:__init__:ARGS: ['move', 'page', 'down']
DEBUG:__init__:cmd parms {'movement': ['page', 'down']}
DEBUG:search:page down
ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:base_events:Task exception was never retrieved
future: <Task finished name='Task-7' coro=<UI._input_filter.<locals>._apply_fire() done, defined at /home/fle/misc/alot/alot/ui.py:193> exception=XapianError()>
Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/search.py", line 252, in apply
    MoveCommand.apply(self, ui)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 1062, in apply
    ui.mainloop.process_input([self.movement])
  File "/usr/lib/python3.8/site-packages/urwid/main_loop.py", line 513, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3.8/site-packages/urwid/container.py", line 1131, in keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/home/fle/misc/alot/alot/buffers/buffer.py", line 29, in keypress
    return self.body.keypress(size, key)
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 975, in keypress
    return actual_key(self._keypress_page_down((maxcol, maxrow)))
  File "/usr/lib/python3.8/site-packages/urwid/listbox.py", line 1391, in _keypress_page_down
    widget, pos = self._body.get_next(pos)
  File "/home/fle/misc/alot/alot/walker.py", line 46, in get_next
    return self._get_at_pos(start_from + self.direction)
  File "/home/fle/misc/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/fle/misc/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/fle/misc/alot/alot/widgets/search.py", line 27, in __init__
    self.rebuild()
  File "/home/fle/misc/alot/alot/widgets/search.py", line 33, in rebuild
    self.thread = self.dbman.get_thread(self.tid)
  File "/home/fle/misc/alot/alot/db/manager.py", line 213, in get_thread
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 195, in _apply_fire
    await self.apply_commandline(cmdline)
  File "/home/fle/misc/alot/alot/ui.py", line 283, in apply_commandline
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read

DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['page up'], [27, 91, 53, 126])
DEBUG:ui:cmdline: 'move page up'
DEBUG:ui:search command string: "move page up"
DEBUG:__init__:mode:search got commandline "move page up"
DEBUG:__init__:ARGS: ['move', 'page', 'up']
DEBUG:__init__:cmd parms {'movement': ['page', 'up']}
DEBUG:search:page up
DEBUG:ui:Got key (['q'], [113])
DEBUG:ui:cmdline: 'exit'
DEBUG:ui:search command string: "exit"
DEBUG:__init__:mode:search got commandline "exit"
DEBUG:__init__:ARGS: ['exit']
DEBUG:__init__:cmd parms {}
DEBUG:globals:flush complete
ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 619, in apply
    ui.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 619, in apply
    ui.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 721, in apply_command
    await cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 76, in apply
    await ui.apply_command(FlushCommand(callback=ui.exit))
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:ui:Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 619, in apply
    ui.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 721, in apply_command
    await cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 76, in apply
    await ui.apply_command(FlushCommand(callback=ui.exit))
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


ERROR:base_events:Task exception was never retrieved
future: <Task finished name='Task-15' coro=<UI._input_filter.<locals>._apply_fire() done, defined at /home/fle/misc/alot/alot/ui.py:193> exception=XapianError()>
Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 619, in apply
    ui.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 721, in apply_command
    await cmd.apply(self)
  File "/home/fle/misc/alot/alot/commands/globals.py", line 76, in apply
    await ui.apply_command(FlushCommand(callback=ui.exit))
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 277, in apply_commandline
    await apply_this_command(c)
  File "/home/fle/misc/alot/alot/ui.py", line 725, in apply_command
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fle/misc/alot/alot/ui.py", line 195, in _apply_fire
    await self.apply_commandline(cmdline)
  File "/home/fle/misc/alot/alot/ui.py", line 283, in apply_commandline
    self._error_handler(e)
  File "/home/fle/misc/alot/alot/ui.py", line 160, in _error_handler
    self.notify(msg, priority='error')
  File "/home/fle/misc/alot/alot/ui.py", line 624, in notify
    self.update()
  File "/home/fle/misc/alot/alot/ui.py", line 660, in update
    lines.append(self.build_statusbar())
  File "/home/fle/misc/alot/alot/ui.py", line 681, in build_statusbar
    info['total_messages'] = self.dbman.count_messages('*')
  File "/home/fle/misc/alot/alot/db/manager.py", line 201, in count_messages
    db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
  File "/usr/lib/python3.8/site-packages/notmuch2/_database.py", line 129, in __init__
    raise errors.NotmuchError(ret, msg)
notmuch2.XapianError: A Xapian exception occurred opening database: Couldn't open /home/fle/mail//.notmuch/xapian/postlist.glass to read

It doesn't throw the same error, but it shows that not all exceptions are caught properly.

@guijemont
Copy link

I was hitting a segfault all the time with the same backtrace, using 424669b. I have now updated to 486df70, using python3-notmuch2 from ubuntu 20.10. I get much less segfault, but I can reliably get a segfault with the steps to reproduce of that issue. This time, the stack trace is a little different (though similar):

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007efcb2964864 in __GI_abort () at abort.c:79
#2  0x00007efcb074f4de in talloc_abort (reason=0x7efcb0759070 "Bad talloc magic value - unknown value") at ../../talloc.c:505
#3  0x00007efcb074f4d7 in talloc_abort_unknown_value () at ../../talloc.c:534
#4  talloc_chunk_from_ptr (ptr=0x375cc70) at ../../talloc.c:534
#5  _talloc_free (ptr=0x375cc70, location=<optimized out>) at ../../talloc.c:1767
#6  0x00007efcb09a9475 in _cffi_f_notmuch_thread_destroy (self=<optimized out>, arg0=<optimized out>) at build/temp.linux-x86_64-3.8/notmuch2._capi.c:4855
#7  0x000000000051dbff in cfunction_vectorcall_O (func=<built-in method notmuch_thread_destroy of _cffi_backend.Lib object at remote 0x7efcb09deb80>, args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>)
    at ../Objects/methodobject.c:482
#8  0x000000000050e7af in _PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7efcaf48fec0, callable=<built-in method notmuch_thread_destroy of _cffi_backend.Lib object at remote 0x7efcb09deb80>)
    at ../Include/cpython/abstract.h:127
#9  call_function (kwnames=0x0, oparg=<optimized out>, pp_stack=<synthetic pointer>, tstate=0x2332980) at ../Python/ceval.c:4963
#10 _PyEval_EvalFrameDefault (f=<optimized out>, throwflag=<optimized out>) at ../Python/ceval.c:3469
#11 0x000000000051ede7 in PyEval_EvalFrameEx
    (throwflag=0, f=Frame 0x7efcaf48fd40, for file /usr/lib/python3/dist-packages/notmuch2/_thread.py, line 38, in _destroy (self=<Thread(_parent=<ThreadIter(_db=<Database(mode=<Mode(_value_=0, _name_='READ_ONLY', __objclass__=<EnumMeta(_generate_next_value_=<function at remote 0x7efcb270e8b0>, __module__='notmuch2._database', __doc__='An enumeration.', _member_names_=['READ_ONLY', 'READ_WRITE'], _member_map_={'READ_ONLY': <...>, 'READ_WRITE': <Mode(_value_=1, _name_='READ_WRITE', __objclass__=<...>) at remote 0x7efcafeba040>}, _member_type_=<type at remote 0x8d2440>, _value2member_map_={0: <...>, 1: <...>}, READ_ONLY=<...>, READ_WRITE=<...>, __new__=<function at remote 0x7efcb270e820>) at remote 0x27541d0>) at remote 0x7efcb09ecd00>, _memptr__db_p_2756640=<_cffi_backend._CDataBase at remote 0x7efcaeffd630>, closed=False) at remote 0x7efcaeffd8e0>, _parent=<Query(_db=<...>, _memptr__query_p_2753770=<_cffi_backend._CDataBase at remote 0x7efcaeffd9c0>) at remote 0x7efcaeffd0d0>, _memptr__iter_p_2745350=<_cffi_backend._CDataBase at...(truncated)) at ../Python/ceval.c:741
#12 function_code_fastcall (globals=<optimized out>, nargs=1, args=<optimized out>, co=<optimized out>) at ../Objects/call.c:283
#13 _PyFunction_Vectorcall (func=<optimized out>, stack=0x7efcaf48fd18, nargsf=<optimized out>, kwnames=<optimized out>) at ../Objects/call.c:410
#14 0x0000000000509abc in _PyObject_Vectorcall (kwnames=0x0, nargsf=<optimized out>, args=0x7efcaf48fd18, callable=<function at remote 0x7efcafed0a60>) at ../Include/cpython/abstract.h:127

You can find the full stack trace here (also with a version form bt full).

The end of my log file looks like this (having replaced names and email addresses):

DEBUG:manager:write-out item: ('toggle', <function TagCommand.apply.<locals>.refresh at 0x7fa91e46a040>, '(tag:inbox AND NOT tag:killed) AND thread:0000000000026cd1', ['unread'])
DEBUG:manager:cmd created
DEBUG:manager:got write lock
DEBUG:manager:got atomic
DEBUG:manager:ended atomic
DEBUG:manager:closed db
DEBUG:manager:<function TagCommand.apply.<locals>.refresh at 0x7fa91e46a040>
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:manager:called callback
DEBUG:manager:flush finished
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|
DEBUG:globals:flush complete
DEBUG:ui:Got key (['page down'], [27, 91, 54, 126])
DEBUG:ui:cmdline: 'move page down'
DEBUG:ui:search command string: "move page down"
DEBUG:__init__:mode:search got commandline "move page down"
DEBUG:__init__:ARGS: ['move', 'page', 'down']
DEBUG:__init__:cmd parms {'movement': ['page', 'down']}
DEBUG:search:page down
DEBUG:utils:unquoted header: |Anne O'nymous <anonymous@example.com>|

@pazz
Copy link
Owner

pazz commented Mar 2, 2021 via email

paretje added a commit to paretje/dotfiles that referenced this issue Mar 19, 2021
After changing a couple of tags, changing the results of the current
search buffer, I get a segfault. (Issue
pazz/alot#1504). I had a look, and there
doesn't seem to be a double free on the Python end, but I have yet to
try if I can reproduce this in C by opening a database, starting a
search, load a messages, open the database a second time, change
the tag of that message, write and close the second database, destroy
the message fetched from the first, and repeat this a couple of times.

Anyway, I still can prevent this segfault by letting the query free the
memory of it's threads, instead of destroying the thread once the Python
object gets destructed.
@boutil
Copy link

boutil commented Nov 8, 2021

Hi! I am also affected by this. I confirm that adding the workaround above in hooks.py prevents alot from aborting after a few tags switchings.

@pazz
Copy link
Owner

pazz commented Nov 8, 2021 via email

@boutil
Copy link

boutil commented Nov 8, 2021

This is 0.10 (the 0.10-1 package, from Debian unstable).
Oh! I have just seen the commit on top of master from last month. That should also probably fix that issue, shouldn't it?

@pazz
Copy link
Owner

pazz commented Nov 8, 2021 via email

@boutil
Copy link

boutil commented Nov 8, 2021

With the latest commit, I cannot reproduce the issue anymore, even without the workaround above. But it is true, as its description says, that it slows down a little the program, noticeably at startup. Thanks for the indication!

paretje added a commit to paretje/dotfiles that referenced this issue Mar 2, 2022
It seems pazz/alot#1504 has been fixed with
recent versions of notmuch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants