php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51487 set_error_handler() misbehave under certain circumstancies
Submitted: 2010-04-06 13:56 UTC Modified: 2013-02-18 00:34 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: fabien dot potencier at symfony-project dot org Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.3.2 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fabien dot potencier at symfony-project dot org
New email:
PHP Version: OS:

 

 [2010-04-06 13:56 UTC] fabien dot potencier at symfony-project dot org
Description:
------------
When throwing an exception from a custom error handler, PHP sometimes dies with a non-obvious error as the actual problem is hidden.

To reproduce, create a simple set_error_handler() and throw an exception (ErrorException here) whenever an error occur (with error_reporting set to -1 for instance).

If you try to output a not-defined variable, you will see the Exception. But, if you call a method on a not-defined variable, the exception is not thrown, and an error message is displayed instead. Debugging is not trivial as the real problem is masked.


Test script:
---------------
set_error_handler(function ($level, $message, $file, $line, $context)
{
  throw new \ErrorException($message);
});

// will throw an Exception (Undefined variable: foo)
// echo $foo;

// will not throw the exception, PHP will try to call bar() instead
$foo->bar();


Expected result:
----------------
PHP Fatal error:  Uncaught exception 'ErrorException' with message 'Undefined variable: foo' in ..:..

Actual result:
--------------
PHP Fatal error:  Call to a member function bar() on a non-object in ... on line 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-06 14:31 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2010-04-06 14:31 UTC] johannes@php.net
bug #51463 might be related, stas also worked on a similar bug where I don't find the commit or bug id right now. Could you pleasetest the latest snapshot, maybe this was fixed. Thanks.
 [2010-04-06 15:07 UTC] fabien dot potencier at symfony-project dot org
I have just tested with php5.3-201004061030, and the problem is not fixed.

The output is indeed better, as the line is not 0 anymore:

Call to a member function call() on a non-object in ... on line 9

instead of:

Call to a member function call() on a non-object in ... on line 0
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC