[Xapian-devel] More weirdness with PHP bindings
Richard Boulton
richard at lemurconsulting.com
Tue Apr 3 16:29:26 BST 2007
Charlie Hull wrote:
> I was surprised it works so well because my script also uses
> get_matching_terms, but it doesn't reproduce the bug above.
> In fact, I don't use a "join(get_matching_terms())" as smoketest do, but
> iterate with get_matching_terms_begin and get_matching_terms_end.
> Just by curiosity, I added the following lines in smoketest.php :
> $hit=$mset->get_hit(0);
> $it=$enq->get_matching_terms_begin($hit);
> while (! $it->equals($enq->get_matching_terms_end($hit)))
> {
> echo $it->get_term(), ' ';
> $it->next();
> }
> and with that code, we get the correct terms. So the bug only concerns
> the way get_matching_terms is wrapped (and only appears under
> windows)... strange.
> "
What were the terms involved in this test? Is it possible that there's
an issue with character set conversion?
Alternatively, it may be a memory management problem: the handling for
get_matching_terms() is special-cases for PHP at the end of
xapian-bindings/php/util.i, where there is code for implementing the
special handling for term lists which allow a list containing the terms
to be obtained. This works by copying each term into the list with
"add_next_index_stringl". Perhaps this isn't copying the contents of
the string correctly, or is failing to allocate space for the contents
correctly.
I've checked through the sources for my version of PHP, and it looks
like the allocation should happen correctly - but there are many layers
of code here, where a problem could be being hidden.
In particular, PHP can use the native allocation routines, or its own
memory allocation system. It would be interesting to try using the
native allocation routines instead of the PHP one to check if there's a
bug in its allocator. (I'm think you can turn off the PHP allocator by
setting the "USE_ZEND_ALLOC" environment variable to "0").
--
Richard
More information about the Xapian-devel
mailing list