[Xapian-tickets] [Xapian] #520: TermIterator::get_term() can fault (core dump with php bindings on windows)
Xapian
nobody at xapian.org
Thu Dec 2 16:48:42 GMT 2010
#520: TermIterator::get_term() can fault (core dump with php bindings on windows)
-----------------------------------+----------------------------------------
Reporter: Daniel.Menard | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: Xapian-bindings (PHP) | Version: 1.2.3
Severity: minor | Keywords:
Blockedby: | Platform: Microsoft Windows
Blocking: |
-----------------------------------+----------------------------------------
Hi,
I'm not sure if this is a bug or just a precision to add to the
documentation, but it is not possible to call
`XapianTermIterator::get_term()` (or `get_termfreq`) if a previous call to
`skip_to()` or `next()` has positioned the internal pointer after the last
term of the database.
For example, this php script generates a GPF on my machine (windows, php
bindings from flax.co.uk, php 5.3.3, Xapian 1.2.3):
{{{
#!php
<?php
$db = Xapian::inmemory_open();
$it = $db->allterms_begin();
$it->skip_to('term');
$it->get_term(); // or $it->get_term_freq();
?>
}}}
The same apply with a not-empty database: `skip_to(last term) + next() +
get_term() = fault`.
Of course, I'm the culprit: I should test for "eof" before trying to
dereference my iterator.
This is what I do, now, and it works well:
{{{
#!php
if (!$it->equals($db->allterms_end()) $it->get_term();
}}}
But I was surprised about Xapian generating a GPF and not an Exception, so
I thought it was worth reporting.
Cheers,
Daniel
PS: I tested with Xapian 1.2.3, but the behavior is the same with version
1.0.16.
--
Ticket URL: <http://trac.xapian.org/ticket/520>
Xapian <http://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list