#41468 [Opn->Fbk]: Exception is not catched in try-catch block in some environment

From: Date: Wed, 23 May 2007 10:30:35 +0000
Subject: #41468 [Opn->Fbk]: Exception is not catched in try-catch block in some environment
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112957@lists.php.net to get a copy of this message
 ID:               41468
 Updated by:       scottmac@php.net
 Reported By:      aleboo at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.2.2
 New Comment:

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.


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

[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)

« previous php.bugs (#112957) next »