#257 closed defect (invalid)
signal 11 on get_docid while iterating postlists in PHP5
Reported by: | Alessandro Pasotti | Owned by: | Olly Betts |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Other | Version: | |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | All |
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 (1)
Change History (3)
by , 17 years ago
Attachment: | bug.tar.gz added |
---|
comment:1 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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
}
comment:2 by , 17 years ago
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?
test case