php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38047 "file" and "line" sometimes not set in backtrace from inside error handler
Submitted: 2006-07-09 13:11 UTC Modified: 2006-07-27 08:22 UTC
From: thuejk at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2006-07-27 OS: *
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: thuejk at gmail dot com
New email:
PHP Version: OS:

 

 [2006-07-09 13:11 UTC] thuejk at gmail dot com
Description:
------------
I generate a backtrace from inside my error handler. Among other things I use the file and line numbers in the error handler.

In one case, inconsistent with behaviour for other types of errors, file and line are not set in the frame for the error handler transition in the backtrace.

I think (without bothering to check) that this error was introduced after I upgraded from 5.0.4 to 5.1.4


Reproduce code:
---------------
<?php
error_reporting(E_ALL);
set_error_handler('kalus_error_handler');
ini_set("display_errors", "on");

class A {
  function A_ftk() {
  }
}

function kalus_error_handler($error_code, $error_string, $filename, $line, $symbols) {
  get_error_context();
}

function get_error_context() {
  $backtrace = debug_backtrace();
  echo $backtrace[1]["line"];
  echo "<pre>";print_r($backtrace);
}

//If this is uncommented, the resulting code will have file and line set for the call into the error handler.
#$a = $aa;

//This will not create file and line items for the call into the error handler
$page["name"] = A::A_ftk();
?>







Expected result:
----------------
  $backtrace[1]["file"]
and
  $backtrace[1]["line"]
should be set.

Actual result:
--------------
Notice: Undefined index: line in /home/tjk/kalus3_clean/trunk/src/web/include/setup.php on line 17

Array
(
    [0] => Array
        (
            [file] => /home/tjk/kalus3_clean/trunk/src/web/include/setup.php
            [line] => 12
            [function] => get_error_context
            [args] => Array
                (
                )

        )

    [1] => Array
        (
            [function] => kalus_error_handler
            [args] => Array
                (
                    [0] => 2048
                    [1] => Non-static method A::A_ftk() should not be called statically
                    [2] => /home/tjk/kalus3_clean/trunk/src/web/include/setup.php
                    [3] => 25
                    [4] => Array
                        (
                            [GLOBALS] => Array
 *RECURSION*
                            [_POST] => Array
                                (
                                )

                            [_GET] => Array
                                (
                                )

                            [_COOKIE] => Array
                                (
                                    [__utma] => 192968248.1592420362.1149610271.1149805566.1149849975.6
                                    [__utmz] => 192968248.1149620260.3.2.utmccn=(referral)|utmcsr=mail.google.com|utmcct=/mail/|utmcmd=referral
                                    [PHPSESSID] => o194fe6r7m7fvgm4do1dspqnk0
                                )

                            [_FILES] => Array
                                (
                                )

                        )

                )

        )

    [2] => Array
        (
            [file] => /home/tjk/kalus3_clean/trunk/src/web/include/setup.php
            [line] => 25
            [function] => A_ftk
            [class] => A
            [type] => ::
            [args] => Array
                (
                )

        )

)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-27 01:30 UTC] sniper@php.net
Verified. Dmitry, you have touched this code the last time, can you take a look?
 [2006-07-27 08:22 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 20:01:33 2024 UTC