php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51394 Error line reported incorrectly iif error handler throws an exception
Submitted: 2010-03-25 21:31 UTC Modified: 2010-04-01 21:37 UTC
From: stas at zend dot com Assigned: stas (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3SVN-2010-03-25 (SVN) OS: *
Private report: No CVE-ID: None
 [2010-03-25 21:31 UTC] stas at zend dot com
Description:
------------
The test script code produces the following error:

[25-Mar-2010 13:25:29] PHP Fatal error:  Function name must be a string in test.php on line 0

This is because there's actually two errors:
1. Undefined $empty notice
2. Function name must be string - fatal error

When error (1) is processed, due to the exception opline_ptr is set to the exception handler opcode, so when the engine wants to report error (2) it doesn't have proper opline_ptr to report the error. 

Test script:
---------------
<?php
function eh()
{
	throw new Exception("error!");
	return false;
}

set_error_handler("eh");
$a = $empty($b);

Expected result:
----------------
[25-Mar-2010 13:25:29] PHP Fatal error:  Function name must be a string in test.php on line 9

Actual result:
--------------
[25-Mar-2010 13:25:29] PHP Fatal error:  Function name must be a string in test.php on line 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-01 21:36 UTC] stas@php.net
Automatic comment from SVN on behalf of stas
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=297301
Log: fix #51394 - try harder to find script lineno when exception happens
 [2010-04-01 21:37 UTC] stas@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: stas
 [2010-04-01 21:37 UTC] stas@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC