Ticket #242 (closed defect: fixed)

Opened 1 year ago

Last modified 2 months ago

exceptions not catched

Reported by: jan1234 Assigned to: hans
Priority: critical Milestone:
Component: Optimizer Version: 0.9.5
Keywords: exceptions Cc: cdri@musicmakesfriends.com

Description

a thrown exception will not be catched, if a there is a user defined exception class. the following code:

<?php

Class MyException extends Exception {}

class A{
    static function b() {
        throw new Exception();
    }
}

try {
    A::b();
} catch (Exception $e) {
    echo 'test';
}

?>

gives:

Fatal error: Uncaught exception 'Exception' in
exceptions.php:7 Stack trace: #0 exceptions.php(12): A::b() #1 {main}
thrown in exceptions.php on line 7

when the eaccelerator chache is on.

version: eAccelerator 0.9.5 [shm:win32 sem:win32] PHP 5.2.1 [ZE 2.2.0] Using apache2handler on Windows NT 5.1 build 2600

Attachments

optimize.c#242.patch (481 bytes) - added by warwickshaw on 08/12/07 00:55:06.
optimize.c_242.patch (481 bytes) - added by warwickshaw on 08/12/07 01:15:46.

Change History

03/07/07 22:21:05 changed by bart

  • owner changed from somebody to hans.
  • component changed from eAccelerator to Optimizer.

This problem is caused by the optimizer, as a workaround you can disable the optimizer.

03/07/07 22:25:48 changed by k7k0

The Try/Catch don't work at all, even with the native Exception class:

try {
    throw new Exception("No");
} catch (Exception $e) { 
    echo "Yes"; 
}

Fatal error: Uncaught exception 'Exception' with message 'No' in....

PHP 5.2.1-0.dotdeb.1 with Suhosin-Patch 0.9.6.2 (cli). Tested with version 0.9.5 and the latest snapshot at the time: svn301

06/01/07 14:43:02 changed by luke

  • owner changed from hans to somebody.
  • priority changed from major to critical.
  • component changed from Optimizer to eAccelerator.

This is a very important bug, that halts use of eAccelerator with every modern php5 app. Try/Catch blocks don't work at all

try this:

try {

throw new Exception("No");

} catch (Exception $e) {

echo "Yes";

}

and it wont work. Config - default. php 5.2.2. Turning off optimizer doesn't change anything.

06/21/07 15:11:29 changed by JonathanO

  • owner changed from somebody to hans.
  • component changed from eAccelerator to Optimizer.

It works fine without the optimizer, so it's clearly an optimizer bug. Did you forget to reload Apache luke?

07/23/07 16:10:13 changed by luke

indeed i forgot to reload Apache :/.

sorry for this.

07/27/07 10:31:28 changed by cdribeta

  • cc set to cdri@musicmakesfriends.com.

Turn off Optimizer and clearing cache will correct this bug. Hope it'll be fixed soon :p

(trying to monitor this bug ... ?)

08/09/07 16:22:21 changed by Eri

Same with Apache on SEL with 5.2.3 :(

08/09/07 16:33:51 changed by hans

  • status changed from new to assigned.

Sorry, i'll look on it asap. Been very busy lately, work and private. Moved to a new appartment etc. :)

08/12/07 00:55:06 changed by warwickshaw

  • attachment optimize.c#242.patch added.

08/12/07 01:07:32 changed by warwickshaw

  • status changed from assigned to closed.
  • resolution set to fixed.

In PHP 5.2.3 the ZEND_JMP opcode can sometimes proceed a ZEND_FETCH_CLASS opocde.

The patch checks for this and sets

p->follow = &bb[line_num];

which is the next basic block leader(ZEND_FETCH_CLASS).

This prevents the optimizer from removing the catch block opcodes.

Tested with all the examples from http://www.w3schools.com/php/php_arrays.asp The examples all throw exceptions!

Warwick Shaw

08/12/07 01:15:46 changed by warwickshaw

  • attachment optimize.c_242.patch added.

08/14/07 13:03:56 changed by hans

Thanks for your work. See [323] . We're thinking of releasing 0.9.5.2 to address this issue.

08/14/07 13:20:19 changed by bart

A test tarball is available here: http://bart.eaccelerator.net/source/eaccelerator-0.9.5.2-test.tar.bz2

Please try it to see if this solves these issues