#41468 [Opn->Bgs]: Exception is not catched in try-catch block in some environment
ID: 41468
Updated by: scottmac@php.net
Reported By: aleboo at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.2
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2007-05-23 10:42:44] aleboo at gmail dot com
Currently situation is like:
I told my hosters (who originally suggested me to create bug report on
bugs.php.net) that it is possible that problem is with optimizers, not
with PHP by it self. After 2 hours everything start working fine, but
they didnt reply me about theyr actions, so I am don't really know for
now what heppened. In my testing environment (I also asked some my
friends to test this case too) everything was allright. So, I think, my
hosting provider fixed it silently but didnt inform me ( well, I was
angry a little :? ). So, it may be still some bug with optimizer, but I
can't provide any info, because has no data about hosting configuration
details and how did they fixed it. Sorry, for wrong alarm, but I simply
forgot about optimizers.
------------------------------------------------------------------------
[2007-05-23 10:30:35] scottmac@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
I can't reproduce this locally with your test case.
------------------------------------------------------------------------
[2007-05-23 08:42:05] aleboo at gmail dot com
Description:
------------
Problem appears in try-catch block in some environment.
When some code throws exception and there is no more any code
right after throwing code in try-catchh block, then exception
is not catched and it falls to system. Other, upper level try-catch
blocks can't catch it too. Not sure about PHP version - it works on
Windows with 5.2.0, it was working on Linux with 5.1.x version, but now
it not working. Introducing die(), or break in the end of internal part
of try-catch blocks sloves the problem, and exception is handled
correcty, but it is offcourse workaround.
Reproduce code:
---------------
class Test{
public function doTest(){
try{
throw new Exception( "test exception" );
// with break or die() here code will work!
}catch( Exception $ex ){
return "exception catched";
}
return "ok";
}
}
$testObj = new Test();
$content = $testObj->doTest();
echo( $content );
Expected result:
----------------
"exception catched" text
Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'test
exception' in /path-to-test-file-dir/test.php:5 Stack trace: #0
/path-to-test-file-dir/test.php(14): Test->doTest() #1 {main} thrown in
/path-to-test-file-dir/test.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41468&edit=1
Thread (4 messages)