[Xapian-tickets] [Xapian] #614: PHP-Bindings & garbage collector

Xapian nobody at xapian.org
Fri Feb 15 10:51:18 GMT 2013


#614: PHP-Bindings & garbage collector
-------------------------+--------------------------------------------------
 Reporter:  Sadrak       |       Owner:  olly  
     Type:  defect       |      Status:  new   
 Priority:  normal       |   Milestone:        
Component:  QueryParser  |     Version:  1.2.13
 Severity:  critical     |    Keywords:        
Blockedby:               |    Platform:  All   
 Blocking:               |  
-------------------------+--------------------------------------------------
 Using a XapianValueRangeProcessor can lead to a segfault. Here is a simple
 example:

 {{{
 #!php
 <?php

 require_once "/path/to/xapian.php";

 $database    = new XapianDatabase('/path/to/database');
 $enquire     = new XapianEnquire($database);
 $queryparser = new XapianQueryParser();

 function add_processor( &$qp ) {
     $price_range_proc = new XapianNumberValueRangeProcessor( 1 );
     $qp->add_valuerangeprocessor($price_range_proc);
     // $price_range_proc run out of scope and get lost
 }

 add_processor( $queryparser );

 // segfault - guess: $price_range_proc was removed by garbage-collector
 $query = $queryparser->parse_query("11000..12000");

 $enquire->set_query($query);

 print "QUERY: ".$query->get_description()."\n";

 $mset = $enquire->get_mset(0, 10, 100);
 $mset_cur = $mset->begin();
 $mset_end = $mset->end();

 print "COUNT: ".$mset->get_matches_estimated()."\n";

 while (!$mset_cur->equals($mset_end)) {
     $id    = $mset_cur->get_document()->get_data();
     $value = Xapian::sortable_unserialise(
 $mset_cur->get_document()->get_value( 2 ) );
     print "$id -> $value\n";
     $mset_cur->next();
 }

 ?>
 }}}

-- 
Ticket URL: <http://trac.xapian.org/ticket/614>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list