hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

debug_backtrace not consistent with Zend when __call is involved

Open franz-deleon opened this issue 12 years ago • 8 comments

Using this:

class A
{
    public function __call($methodName, $args)
    {
        var_dump(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
    }
}

$a = new A;
$a->someNonExistingFunc();

Result in PHP:

$ php backtrace.php 
array(2) {
  [0] =>
  array(5) {
    'file' =>
    string(41) "/vagrant/www/fdldebug/tests/backtrace.php"
    'line' =>
    int(11)
    'function' =>
    string(6) "__call"
    'class' =>
    string(1) "A"
    'type' =>
    string(2) "->"
  }
  [1] =>
  array(5) {
    'file' =>
    string(41) "/vagrant/www/fdldebug/tests/backtrace.php"
    'line' =>
    int(11)
    'function' =>
    string(19) "someNonExistingFunc"
    'class' =>
    string(1) "A"
    'type' =>
    string(2) "->"
  }
}

Result in HHVM

$ hhvm backtrace.php 
array(1) {
  [0]=>
  array(5) {
    ["file"]=>
    string(41) "/vagrant/www/fdldebug/tests/backtrace.php"
    ["line"]=>
    int(11)
    ["function"]=>
    string(6) "__call"
    ["class"]=>
    string(1) "A"
    ["type"]=>
    string(2) "->"
  }
}

It seems like the reference to the non existing function that __call is using is not being outputted

franz-deleon avatar Feb 28 '14 17:02 franz-deleon

may be same as #1018 ?

karpa13a avatar Feb 28 '14 17:02 karpa13a

sucks they tag this as wont fix. I am writing something that depends on debug_backtrace :\

franz-deleon avatar Feb 28 '14 18:02 franz-deleon

@franz-deleon as u can see, we too)

karpa13a avatar Feb 28 '14 18:02 karpa13a

This isn't the same issue as #1018 - class_exist() isn't actually implemented as a function call in HHVM. The Zend behavior is strange here, given that the function in the back trace doesn't exist. Why do you need this behavior, given that the method name gets passed to __call anyway?

fredemmott avatar Feb 28 '14 18:02 fredemmott

@freddemmott i need a way to trace back where __call is called refering the non existing function that zend created on its back trace. my example is a simpler version and using call is really irrelevant and i have to grab the data from the debug_backtrace

franz-deleon avatar Feb 28 '14 19:02 franz-deleon

Sorry, could you provide a more thorough example or explanation as to why you need to get the data this way?

fredemmott avatar Feb 28 '14 19:02 fredemmott

@fredemmott I have to grab the file and line number where the function is called. I can use the __call trace data but I do not think its too reliable compared to where "function" array key where the non existing function is named.

franz-deleon avatar Feb 28 '14 20:02 franz-deleon

I don't think we're going to support this; if you share your code or submit a pull request, we'd be happy to make suggestions, and possibly reconsider.

fredemmott avatar Feb 28 '14 21:02 fredemmott