[Xapian-tickets] [Xapian] #257: signal 11 on get_docid while iterating postlists in PHP5

Xapian nobody at xapian.org
Fri Apr 25 09:20:21 BST 2008


#257: signal 11 on get_docid while iterating postlists in PHP5
--------------------+-------------------------------------------------------
 Reporter:  elpaso  |        Owner:  olly   
     Type:  defect  |       Status:  closed 
 Priority:  normal  |    Milestone:         
Component:  Other   |      Version:         
 Severity:  normal  |   Resolution:  invalid
 Keywords:          |    Blockedby:         
 Platform:  All     |     Blocking:         
--------------------+-------------------------------------------------------
Changes (by olly):

  * status:  new => closed
  * resolution:  => invalid


Comment:

 You're accessing $i->get_docid() after calling $i->next() but before
 checking !$i->equals($this->database->postlist_end('').  It's not valid to
 call methods
 on an iterator which has reached the end of the sequence, since it then
 points
 to just '''AFTER''' the end of the iterated sequence, not the last
 element.
 See bold comments added below:

                 $onemore = false;
                 $i = $this->database->postlist_begin('');
                 print "First : " . $i->get_docid() . "\n";
                 print "Last : " . $this->database->get_lastdocid() . "\n";
                 while(!$i->equals($this->database->postlist_end(''))){
                         $this->delete_document($i->get_docid());
                         print("del : ".$i->get_docid() . "\n");
                         $i->next();
                         $onemore = true;
                         print("next : " .$i->get_docid() . "\n"); '''//
 This may be invalid'''
                 }
                 if($onemore){
                         $this->delete_document($i->get_docid()); '''//
 This WILL be invalid'''
                 }

-- 
Ticket URL: <http://trac.xapian.org/ticket/257#comment:1>
Xapian <http://trac.xapian.org>
Xapian



More information about the Xapian-tickets mailing list