unofficial mirror of
 help / color / Atom feed
From: Floris Bruynooghe <>
Subject: Usage after database close
Date: Sun, 28 Jun 2020 15:57:17 +0200
Message-ID: <> (raw)


I started writing some test cases to define better what you can do with
a closed database and make sure that the python bindings do not behave
unexpectedly here too.

One of the first things I tried ends up with xapian calling
exit_group(2) directly, terminating the process.  So I'm wondering if
I'm approaching this entirely the wrong way.  My understanding is that
we should generally be allowed to use anything after the database has
been closed, as long as nothing has been destroyed.

Below is a minimal reproducible example of what I'm testing so far.  I
must admit I'm generally lazy here and usually just test with notmuch
that is currently in Debian testing.


Here the script:


MAILDIR=$(mktemp --directory)
export MAILDIR

mkdir $MAILDIR/tmp
mkdir $MAILDIR/new
mkdir $MAILDIR/cur

cat > $MAILDIR/notmuch-config <<EOF
name=Some Hacker


cat > $MAILDIR/cur/1593342032.M818430P304029Q3.powell <<EOF
Received: by MailDir; Sun Jun 28 13:00:32 2020
Message-ID: <>
Date: Sun, 28 Jun 2020 13:00:32 -0000
Subject: Test mail
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0

This is a test mail

notmuch new

cat >$MAILDIR/test.c <<EOF
#include <stdio.h>
#include <notmuch.h>

int main(int argc, char** argv) {
    notmuch_status_t status;
    notmuch_database_t* db;
    notmuch_message_t* msg;
    const char* messageid;
    printf("Opening db\n");
    status = notmuch_database_open(argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
    if (status != NOTMUCH_STATUS_SUCCESS) {
        return status;
    printf("Finding msg\n");
    status = notmuch_database_find_message(db, "", &msg);
    if (status != NOTMUCH_STATUS_SUCCESS) {
        return status;
    printf("Closing db\n");
    status = notmuch_database_close(db);
    if (status != NOTMUCH_STATUS_SUCCESS) {
        return status;
    printf("Get messageid\n");
    messageid = notmuch_message_get_message_id(msg);
    if (messageid == NULL) {
        return 1;
    printf("Messageid: %s\n", messageid);
    printf("The end.\n");

gcc $MAILDIR/test.c -lnotmuch -o $MAILDIR/test


             reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-28 13:57 Floris Bruynooghe [this message]
2020-06-28 16:19 ` David Bremner
2020-06-28 20:47   ` Floris Bruynooghe
2020-06-28 22:11     ` David Bremner
2020-06-28 22:24       ` David Bremner
2020-06-29 14:39         ` David Bremner
2020-06-29 21:18       ` Floris Bruynooghe

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:

  List information:

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

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

unofficial mirror of

Archives are clonable:
	git clone --mirror notmuch/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 notmuch notmuch/ \
	public-inbox-index notmuch

Example config snippet for mirrors

Newsgroups are available over NNTP:

AGPL code for this site: git clone