Your message dated Sat, 10 Nov 2018 11:17:56 +0000
with message-id <[email protected]>
and subject line Bug#912883: fixed in xapian-core 1.4.3-2+deb9u3
has caused the Debian Bug report #912883,
regarding libxapian30: freelist block leaks which are reported as corruption
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
912883: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=912883
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libxapian30
Version: 1.4.3-2+deb9u1
Severity: important
Tags: patch upstream

If changes to a new database which don't modify the termlist table
are committed, then a block which has been allocated to be the root
block in the termlist table gets leaked.  This case is triggered by
notmuch - the result is a database which is slightly larger than
it would otherwise be, but works fine *except* that consistency
checking with xapian-check/Database::check() detects there's an
unused block not on the freelist and reports this as
"DatabaseCorruptError" - this tends to alarm users.

While tracking down the above problem, I found a second case where
blocks can be leaked when cancel_transaction() is called.

Both of these were fixed in upstream xapian-core 1.4.7 - the combined
patch is attached.

Cheers,
    Olly
diff --git a/xapian-core/backends/glass/glass_table.cc b/xapian-core/backends/glass/glass_table.cc
index 7342f7496c48..1669431b6c6c 100644
--- a/xapian-core/backends/glass/glass_table.cc
+++ b/xapian-core/backends/glass/glass_table.cc
@@ -1639,6 +1639,7 @@ GlassTable::read_root()
 	    /* writing - */
 	    SET_REVISION(p, revision_number + 1);
 	    C[0].set_n(free_list.get_block(this, block_size));
+	    C[0].rewrite = true;
 	}
     } else {
 	/* using a root block stored on disk */
@@ -1853,9 +1854,7 @@ GlassTable::flush_db()
 	}
     }
 
-    if (Btree_modified) {
-	faked_root_block = false;
-    }
+    faked_root_block = false;
 }
 
 void
@@ -1944,6 +1943,13 @@ GlassTable::cancel(const RootInfo & root_info, glass_revision_number_t rev)
     item_count =       root_info.get_num_entries();
     faked_root_block = root_info.get_root_is_fake();
     sequential =       root_info.get_sequential();
+    const string & fl_serialised = root_info.get_free_list();
+    if (!fl_serialised.empty()) {
+	if (!free_list.unpack(fl_serialised))
+	    throw Xapian::DatabaseCorruptError("Bad freelist metadata");
+    } else {
+	free_list.reset();
+    }
 
     Btree_modified = false;
 
diff --git a/xapian-core/tests/api_backend.cc b/xapian-core/tests/api_backend.cc
index a520be112286..a6d97742865f 100644
--- a/xapian-core/tests/api_backend.cc
+++ b/xapian-core/tests/api_backend.cc
@@ -1666,3 +1666,23 @@ DEFINE_TESTCASE(checkatleast4, backend) {
     TEST_EQUAL(mset.size(), 0);
     return true;
 }
+
+/// Regression test for glass bug fixed in 1.4.6 and 1.5.0.
+DEFINE_TESTCASE(nodocs1, transactions && !remote) {
+    {
+	Xapian::WritableDatabase db = get_named_writable_database("nodocs1");
+	db.set_metadata("foo", "bar");
+	db.commit();
+	Xapian::Document doc;
+	doc.add_term("baz");
+	db.add_document(doc);
+	db.commit();
+    }
+
+    size_t check_errors =
+	Xapian::Database::check(get_named_writable_database_path("nodocs1"),
+				Xapian::DBCHECK_SHOW_STATS, &tout);
+    TEST_EQUAL(check_errors, 0);
+
+    return true;
+}
diff --git a/xapian-core/tests/api_transdb.cc b/xapian-core/tests/api_transdb.cc
index eda0a6ef5936..32eede143f5a 100644
--- a/xapian-core/tests/api_transdb.cc
+++ b/xapian-core/tests/api_transdb.cc
@@ -1,7 +1,7 @@
 /** @file api_transdb.cc
  * @brief tests requiring a database backend supporting transactions
  */
-/* Copyright (C) 2006,2009 Olly Betts
+/* Copyright (C) 2006,2009,2018 Olly Betts
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -126,3 +126,24 @@ DEFINE_TESTCASE(canceltransaction2, transactions) {
 
     return true;
 }
+
+/// Regression test for glass bug fixed in 1.4.6 and 1.5.0.
+DEFINE_TESTCASE(canceltransaction3, transactions && !remote) {
+    {
+	Xapian::WritableDatabase db = get_named_writable_database("canceltransaction3");
+	db.begin_transaction();
+	Xapian::Document doc;
+	doc.add_term("baz");
+	db.add_document(doc);
+	db.cancel_transaction();
+	db.add_document(doc);
+	db.commit();
+    }
+
+    size_t check_errors =
+	Xapian::Database::check(get_named_writable_database_path("canceltransaction3"),
+				Xapian::DBCHECK_SHOW_STATS, &tout);
+    TEST_EQUAL(check_errors, 0);
+
+    return true;
+}

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Source: xapian-core
Source-Version: 1.4.3-2+deb9u3

We believe that the bug you reported is fixed in the latest version of
xapian-core, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Olly Betts <[email protected]> (supplier of updated xapian-core package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Mon, 05 Nov 2018 07:47:57 +1300
Source: xapian-core
Binary: libxapian30 libxapian30-dbg libxapian-dev xapian-tools xapian-doc 
xapian-examples
Architecture: source
Version: 1.4.3-2+deb9u3
Distribution: stretch
Urgency: medium
Maintainer: Olly Betts <[email protected]>
Changed-By: Olly Betts <[email protected]>
Description:
 libxapian-dev - Development files for Xapian search engine library
 libxapian30 - Search engine library
 libxapian30-dbg - Debugging symbols for the Xapian Search engine library
 xapian-doc - Core Xapian documentation
 xapian-examples - Xapian simple example programs
 xapian-tools - Basic tools for Xapian search engine library
Closes: 912883
Changes:
 xapian-core (1.4.3-2+deb9u3) stretch; urgency=medium
 .
   * fix-freelist-leaks.patch: Fix leaks of freelist blocks in corner cases
     which then get reported as "DatabaseCorruptError" by Database::check().
     (Closes: #912883)
Checksums-Sha1:
 de419f7013ee13a2d752c6a48a05ab798a6c3ce5 2242 xapian-core_1.4.3-2+deb9u3.dsc
 722fc9a020afb11746d62d2340dc9fcc1ada1c16 21844 
xapian-core_1.4.3-2+deb9u3.debian.tar.xz
 ecdeddf4432ef6efce3279e6c064db925aa50a0f 7407 
xapian-core_1.4.3-2+deb9u3_amd64.buildinfo
Checksums-Sha256:
 0a53ce128aab772a721015d22c82df194b5c124e7bd6c91d358efc4ab69aaaa6 2242 
xapian-core_1.4.3-2+deb9u3.dsc
 98aecd32eb84bb3a0f219799e7ced829e35eb6bfd3ad15282fc3e67e1a984dae 21844 
xapian-core_1.4.3-2+deb9u3.debian.tar.xz
 c57efe331259c65af4988cf45198cb090bc132435b2ec4f51029ae3c34ac6bf8 7407 
xapian-core_1.4.3-2+deb9u3_amd64.buildinfo
Files:
 efbb439c911d70b194cbf8fc2859aadc 2242 libs important 
xapian-core_1.4.3-2+deb9u3.dsc
 c3c3fb040f29119fdc20d703ee757d9d 21844 libs important 
xapian-core_1.4.3-2+deb9u3.debian.tar.xz
 fdbb9dfbcb5d2df74db9974532f73f0d 7407 libs important 
xapian-core_1.4.3-2+deb9u3_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEECOJAD/f+j+3jrLUoGBR7BzutKwcFAlvh7l0ACgkQGBR7Bzut
KwcnZxAAuXhVYU9S7XMBzsb6EqiGqSKQR8btgkSql+JBlgMpmgQpY8eE6WJ1/17v
gBkLiXQN8mhz6QzxjXPi2gMkJ0p9ttG6SAcz6jSOIh9OYWsNuhxeaDDIeKscg+3e
j7qFcPKoInBQKpqED36SvQrOcZxkBwoD2t3JyX2epGpSjRKmi+Gf6j4xtRX7Nk0Q
HPLRkCBLbaUiaTv/MoXJIw4YgyHbJjkVBejvWcV9BTHOYNIMoyBLAGyQhRHJ0MyQ
YG/Ee9aj79Lfhdqt4fHx2B1Gftk5l4U+AvokGOp6qfmzWUQNe3sQoSWCNLzhZOt0
Vdfx2kHMplyKWFQBS+q+jseVCynWNoCXIEJNQ1GjiixveCDWOq5TzzZTMS3nusTX
bw94vu8kHpwo6WFh96xGzW5o8cXf/XvuzD6gXVialgGgA4UorUAnANRgrkMhimZt
lgZTbV9oM06bq2ygZGYokL6QQxQ29WlFg8rjd6dEZlAH2xBZ04a0tRLvivh17YlI
z/p40fvhD2MHP2aELzl94mysqB8gSsijj28o1zUK8H/Fr3HsdTzk0dMHX9yepfKU
VkhjhPujiJO80OpuyAkp+hPQHXsJQDFLqqNCmpVY5+KGGQM5XmIsKnZxWcxLHmXc
VoVo3aXv6TwjQhwQkAgj2WPISE2sghZ7dh13tXr7wboICHA5k/k=
=rKju
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to