Public bug reported:
update-apt-xapian-index fails on this system and cannot succeed, leaving the
machine with no package index at all:
File "/usr/lib/python3/dist-packages/axi/indexer.py", line 604, in
get_document_from_apt
addon.obj.index(document, pkg)
File "/usr/share/apt-xapian-index/plugins/relations.py", line 132, in index
self._index_rel(pfx, val, document)
File "/usr/share/apt-xapian-index/plugins/relations.py", line 116, in
_index_rel
doc.add_term(pfx + name.split(None, 1)[0])
IndexError: list index out of range
The cause is in the relations plugin:
for name in self.re_split.split(val):
doc.add_term(pfx + name.split(None, 1)[0])
re.split() returns [""] for an empty string, and "".split(None, 1) is [], so
indexing [0] raises IndexError whenever a token is empty. That happens when a
relationship field is PRESENT BUT EMPTY - "Depends:" with nothing after the
colon - and equally for a stray or trailing separator, as in "Depends: libc6,".
The caller only skips a field that is absent (rec.get(field, None) returns None
and continues), so a field that exists with an empty value reaches this code.
What makes it worth reporting is the blast radius rather than the typo. One
document is built per package, so the exception propagates out of
get_document_from_apt() through buildIndex() and rebuild(), and the whole
rebuild dies. A single malformed field in any package in any configured
repository is therefore enough to leave the system with no index, failing
identically on every subsequent run, after spending the CPU and memory to get
there (about 5 seconds and 164 MB here).
This is not hypothetical. On this machine eleven packages from a third-party
apt repository each ship "Depends:" with an empty value, and
apt-xapian-index.service had never once completed. I have reported the empty
field to that repository separately - it should not emit it - but the plugin
should not be destroyed by it either.
The patch below skips empty tokens. index() and indexDeb822() both funnel
through _index_rel(), so it covers the apt and the Deb822 paths, and that is
the only occurrence of the pattern in the tree. With it applied the indexer
completes in 17 seconds on this machine against the same packages.
It also adds TestRelationsPlugin to test/test_indexer.py, covering an empty
field, a whitespace-only field, a trailing separator and a doubled separator
alongside the ordinary and alternative-dependency cases. Four of the six fail
against the current code with the IndexError above; all six pass with the
patch, under nose2:
testAlternatives (test_indexer.TestRelationsPlugin) ... ok
testDoubledSeparator (test_indexer.TestRelationsPlugin) ... ok
testEmptyField (test_indexer.TestRelationsPlugin) ... ok
testOrdinaryField (test_indexer.TestRelationsPlugin) ... ok
testTrailingSeparator (test_indexer.TestRelationsPlugin) ... ok
testWhitespaceOnlyField (test_indexer.TestRelationsPlugin) ... ok
A note on running them. "./runtests" could not collect them here, and the
four existing TestIndexer tests error on this Python, so I ran nose2 from
inside test/ instead:
cd test && python3 -m nose2 -v test_indexer
Neither of those is caused by this patch - my commit only appends to
test/test_indexer.py and removes no line from it - and both are reported
separately so that this one stays about the IndexError and its fix.
-- System Information:
Distribution: Ubuntu 26.10 (stonking)
Architecture: amd64
Python: 3.14.8
apt-xapian-index: 0.59
Also reported to Debian as https://bugs.debian.org/1155492 , with the
same patch attached.
** Affects: apt-xapian-index (Ubuntu)
Importance: Undecided
Status: New
** Tags: patch
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2177236
Title:
an empty relationship field aborts the entire index rebuild
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt-xapian-index/+bug/2177236/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs