[Lars Luthman] Bug#826843: Calls to notmuch_database_add_message() after notmuch_database_close() crash

Subject: [Lars Luthman] Bug#826843: Calls to notmuch_database_add_message() after notmuch_database_close() crash

Date: Thu, 09 Jun 2016 15:06:58 -0300

To: notmuch@notmuchmail.org

Cc:

From: David Bremner


Package: libnotmuch-dev
Version: 0.18.2-1
Severity: important

In the API documentation for notmuch_database_close() it says:

 * After notmuch_database_close has been called, calls to other
 * functions on objects derived from this database may either behave
 * as if the database had not been closed (e.g., if the required data
 * has been cached) or may fail with a
 * NOTMUCH_STATUS_XAPIAN_EXCEPTION.

However, if you call notmuch_database_close() on a database and then
call notmuch_database_add_message(), it doesn't fail nicely with a
NOTMUCH_STATUS_XAPIAN_EXCEPTION, it segfaults.

This should either be fixed so it doesn't crash, as documented, or the
documentation should be changed to describe which functions are unsafe
to call after notmuch_database_close().

I'm attaching a small C program to reproduce the bug. It crashes with
the following backtrace:

(gdb) bt
#0  0xb71f3f27 in Xapian::WritableDatabase::begin_transaction(bool) ()
   from /usr/lib/sse2/libxapian.so.22
#1  0xb779480d in notmuch_database_begin_atomic ()
   from /usr/lib/i386-linux-gnu/libnotmuch.so.3
#2  0xb7794fa0 in notmuch_database_add_message ()
   from /usr/lib/i386-linux-gnu/libnotmuch.so.3
#3  0x080488d3 in add_new_email (db=0x82b5610, 
    filename=0x8048b51 "/new-mail-2@example.net:2,", content=0x8048b30
"hello")
    at notmuchcrash.c:27
#4  0x080489d7 in main () at notmuchcrash.c:52


Installed version of libxapian22: 1.2.19-1+deb8u1


-- System Information:
Debian Release: 8.5
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 3.16.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libnotmuch-dev depends on:
ii  libnotmuch3  0.18.2-1

libnotmuch-dev recommends no packages.

libnotmuch-dev suggests no packages.

-- no debconf information
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: