Ticket #257 (closed defect: invalid)

Opened 9 months ago

Last modified 9 months ago

signal 11 on get_docid while iterating postlists in PHP5

Reported by: elpaso Owned by: olly
Priority: normal Milestone:
Component: Other Version:
Severity: normal Keywords:
Cc: Blocked By:
Operating System: All Blocking:

Description

I'm testing SVN clustering branch from PHP5.

While trying to iterate documents in order to delete them, I've got a sigfault.

The attached test case should reproduce the bug, the sigfault happens while trying to access the last document in the posting list.

Attachments

bug.tar.gz (3.0 kB) - added by elpaso 9 months ago.
test case

Change History

Changed 9 months ago by elpaso

test case

Changed 9 months ago by olly

  • status changed from new to closed
  • resolution set to invalid

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

}

Changed 9 months ago by elpaso

Yes, I see it was an error but a segfault is not a graceful exit, no way to implement range checks in the C++ code?

Note: See TracTickets for help on using tickets.