php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47284 Args disappear from exception stack trace (works in 5.3)
Submitted: 2009-02-02 22:38 UTC Modified: 2012-08-12 12:39 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: thekid@php.net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2CVS-2009-04-25 OS: *
Private report: No CVE-ID: None
 [2009-02-02 22:38 UTC] thekid@php.net
Description:
------------
Exception's stacktraces miss the "args" key in certain situations (whereas debug_backtrace() will report them).

Reproduce code:
---------------
php -r 'class Chained extends Exception { function __construct($message, $cause) { parent::__construct($message); $this->cause= $cause; }} function raise($message, $cause) { throw new Chained($message, new Exception($cause)); } try { raise("Arg", "Cause"); } catch (Exception $e) { var_dump($e->getTrace(), $e->cause->getTrace()); }'

Expected result:
----------------
Twice this:

array(1) {
  [0]=>
  array(4) {
    ["file"]=>
    string(17) "Command line code"
    ["line"]=>
    int(1)
    ["function"]=>
    string(5) "raise"
    ["args"]=>
    array(2) {
      [0]=>
      &string(3) "Arg"
      [1]=>
      &string(5) "Cause"
    }
  }
}


Actual result:
--------------
array(1) {
  [0]=>
  array(4) {
    ["file"]=>
    string(17) "Command line code"
    ["line"]=>
    int(1)
    ["function"]=>
    string(5) "raise"
    ["args"]=>
    array(2) {
      [0]=>
      string(3) "Arg"
      [1]=>
      string(5) "Cause"
    }
  }
}
array(1) {
  [0]=>
  array(3) {
    ["file"]=>
    string(17) "Command line code"
    ["line"]=>
    int(1)
    ["function"]=>
    string(5) "raise"
  }
}

The second array is missing the "args" key. In PHP 5.3, it's present.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-09 21:23 UTC] thekid@php.net
Doesn't help, I tried PHP 5.2 from CVS, which yields the same result:

== php -v ==
PHP 5.2.9RC2-dev (cli) (built: Feb  9 2009 08:46:53) (DEBUG)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

== Results ==
array(1) {
  [0]=>
  array(4) {
    ["file"]=>
    string(17) "Command line code"
    ["line"]=>
    int(1)
    ["function"]=>
    string(5) "raise"
    ["args"]=>
    array(2) {
      [0]=>
      string(3) "Arg"
      [1]=>
      string(5) "Cause"
    }
  }
}
array(1) {
  [0]=>
  array(3) {
    ["file"]=>
    string(17) "Command line code"
    ["line"]=>
    int(1)
    ["function"]=>
    string(5) "raise"
  }
}
 [2012-08-10 16:26 UTC] laruence@php.net
-Status: Verified +Status: Not a bug
 [2012-08-10 16:26 UTC] laruence@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2012-08-12 12:39 UTC] thekid@php.net
> Unfortunately you are not using a current version of PHP 

Three years ago when I reported this, I was:)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 10:01:31 2024 UTC