ID:               32674
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rashid at ds dot pg dot gda dot pl
-Status:           Open
+Status:           Verified
-Bug Type:         Reproducible crash
+Bug Type:         Zend Engine 2 problem
-Operating System: win 2000
+Operating System: *
-PHP Version:      5CVS-2005-04-11 (dev)
+PHP Version:      5CVS-2005-04-11
 New Comment:

I get this:

Fatal error: Invalid opcode 137/1/8. in /home/jani/t.php on line 50



Previous Comments:
------------------------------------------------------------------------

[2005-04-11 17:26:08] rashid at ds dot pg dot gda dot pl

Description:
------------
If you create class implementing Iterator interface and exception
happens during foreach than hell breaks loose. After exception in
foreach debugger shows, that processing is continued in line after the
loop. In this situation exception should be thrown further. Instead it
looks like exception is being kept somewhere while processing continues
and is being thrown at end of the script (end of scope?).

Normally (ie. operations on non-objects) this doesn`t cause crash, but
if you assign object member after interrupted loop, then apache dies
(1.3.28).

Apart from latest shapshot the problem is present also in 5.0.3, didn`t
check 5.0.4.

Reproduce code:
---------------
<?php
class collection implements Iterator {

  private $_elements = array();

  public function __construct() {
  }


  public function rewind() {
    reset($this->_elements);
  }

  public function count() {
    return count($this->_elements);
  }

  public function current() {
    $element = current($this->_elements);
    return $element;
  }

  public function next() {
    $element = next($this->_elements);
    return $element;
  }

  public function key() {
    $this->_fillCollection();
    $element = key($this->_elements);
    return $element;
  }

  public function valid() {
    throw new Exception('shit happend');

    return ($this->current() !== false);
  }
}

class class2 {
  public $dummy;
}

$obj = new class2();
$col = new collection();
$dummy = 'nothing';

foreach($col as $co) {
  //irrelevant
}

echo 'shouldn`t get here';
//$dummy = 'this will not crash'; 
$obj->dummy = 'this will crash';
?>

Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'shit happend'
in d:\projects\opcapp\htdocs\collcrash.php:35 Stack trace: #0
d:\projects\opcapp\htdocs\collcrash.php(35): collection::valid() #1
d:\projects\opcapp\htdocs\collcrash.php(49): collection::valid() #2
d:\projects\opcapp\htdocs\collcrash.php(49): unknown() #3 {main} thrown
in d:\projects\opcapp\htdocs\collcrash.php on line 35

Actual result:
--------------
apache crash 

or (if you comment out the bottom line and remove comment from the one
above it)

shouldn`t get here
Fatal error: Uncaught exception 'Exception' with message 'shit happend'
in d:\projects\opcapp\htdocs\collcrash.php:35 Stack trace: #0
d:\projects\opcapp\htdocs\collcrash.php(35): collection::valid() #1
d:\projects\opcapp\htdocs\collcrash.php(49): collection::valid() #2
d:\projects\opcapp\htdocs\collcrash.php(49): unknown() #3 {main} thrown
in d:\projects\opcapp\htdocs\collcrash.php on line 35


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32674&edit=1

Reply via email to