segfault in T590-libconfig notmuch_database_get_config_list: closed db

Subject: segfault in T590-libconfig notmuch_database_get_config_list: closed db

Date: Tue, 27 Oct 2020 11:09:16 +0100

To: notmuch@notmuchmail.org

Cc:

From: Olivier Taïbi


The test mentioned in the subject triggers a segfault.  This is with
xapian-core-1.4.16 on OpenBSD.  Here is the backtrace:

#0  0x000005c9d491bec2 in Xapian::TermIterator::decref() () from /usr/local/lib/libxapian.so.5.1
#1  0x000005c948827062 in Xapian::TermIterator::~TermIterator (this=0x5c9d2fdb068) at /usr/local/include/xapian/termiterator.h:85
#2  _notmuch_config_list_destroy (list=<optimized out>) at lib/config.cc:38
#3  0x000005c97e08050a in ?? () from /usr/local/lib/libtalloc.so.1.1
#4  0x000005c94882700f in notmuch_database_get_config_list (notmuch=0x5c9cb714e60, prefix=<optimized out>, out=0x7f7ffffc98e8) at lib/config.cc:137
#5  0x000005c6ff617c37 in main (argc=2, argv=0x7f7ffffc9998) at test2.c:16

For convenience, here is test2.c:
<----- begin test2.c ----->
#include <string.h>
#include <stdlib.h>
#include <notmuch-test.h>

int main (int argc, char** argv)
{
   notmuch_database_t *db;
   char *val;
   notmuch_status_t stat;

   EXPECT0(notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db));

{
   notmuch_config_list_t *list;
   EXPECT0(notmuch_database_close (db));
   stat = notmuch_database_get_config_list (db, "nonexistent", &list);
   printf("%d\n", stat == NOTMUCH_STATUS_XAPIAN_EXCEPTION);
}
   EXPECT0(notmuch_database_destroy(db));
}
<----- end test2.c ----->

In frame 4, we see that the iterator was not initialized:
(gdb) p *list
$7 = {notmuch = 0x5c9cb714e60, iterator = {internal = 0xdfdfdfdfdfdfdfdf}, current_key = 0x0, current_val = 0x0}
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: