View Issue Details

IDProjectCategoryView StatusLast Update
0001259XdebugTracingpublic2020-03-12 16:49
Reportermindplay Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionwon't fix 
PlatformAny PHP versionOSAny OS 
Summary0001259: Stack trace print-outs in reverse order
Description

The stack-trace print-outs are in backwards order compared with PHP itself, and compared with stack-traces in other languages, including Java and C#, as well as stack-trace print-outs in a JavaScript developer console.

It's very distracting and confusing to have to figure out the order of every stack trace you see during a day, and I'd like to request this be changed and made consistent with PHP itself.

Steps To Reproduce

An example stack trace from PHP 7 without xdebug:

<code>
Rasmus Schultz@Sidewinder-7240 MINGW64 /c
$ php -r "function foo() { throw new RuntimeException; } function bar() { foo(); } function baz() { bar(); } baz();"
PHP Fatal error: Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
0000002 Command line code(1): baz()
0000003 {main}
thrown in Command line code on line 1

Fatal error: Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
0000002 Command line code(1): baz()
0000003 {main}
thrown in Command line code on line 1
</code>

And an example stack trace with xdebug:

<code>
$ php -r "function foo() { throw new RuntimeException; } function bar() { foo(); } function baz() { bar(); } baz();"
PHP Fatal error: Uncaught RuntimeException in Command line code:1
Stack trace:
#0 Command line code(1): foo()
#1 Command line code(1): bar()
0000002 Command line code(1): baz()
0000003 {main}
thrown in Command line code on line 1

Fatal error: Uncaught RuntimeException in Command line code on line 1

RuntimeException: in Command line code on line 1

Call Stack:
0.0001 360720 1. {main}() Command line code:0
0.0001 360720 2. baz() Command line code:1
0.0001 360720 3. bar() Command line code:1
0.0001 360720 4. foo() Command line code:1
</code>

In the latter case, we actually have two stack traces on screen at the same time, in opposing order - pretty confusing.

TagsNo tags attached.
Operating System
PHP Version7.0.0-7.0.4

Activities

mindplay

2016-01-21 09:43

reporter   ~0003430

My example was mangled by Mantis, and it seems I can't edit this issue, so here's a readable gist with the examples:

https://gist.github.com/mindplay-dk/d50205f38f1d0cf3744f

mindplay

2016-01-21 10:10

reporter   ~0003431

Note that I have reported this issue against php-unit as well - likely taking inspiration from xdebug, php-unit also displays stack-traces in backwards order.

https://github.com/sebastianbergmann/phpunit/issues/2044

derick

2016-02-08 21:12

administrator   ~0003459

Thanks for your request. I am not going to change this. It would render most tests invalid, all online docs and tutorials. Please just consider this a quirk of Xdebug (and PHP Unit).

vaxquis

2018-11-29 14:24

reporter   ~0004728

@derick why can we just have a config var that would allow to reverse this, with a default setting equal to current, legacy behaviour? That way all the tests would be still valid, all the online docs and tutorials too.

Nb saying "please just consider this a quirk" about a behaviour that clearly violates POLA and differs from both platform (PHP's) and industry standards without providing any clear benefit to end-user is, to say the least, bizzare IMO.

derick

2018-11-29 14:41

administrator   ~0004729

@vaxquis: PHP added stack traces after Xdebug had them for years, so PHP is inconsistent with Xdebug, if you must compare them.

It also wouldn't mean that "the tests would be still valid", as for each feature/setting, there need to be tests.

I'm not going to change this, nor add a configuration setting.

Issue History

Date Modified Username Field Change
2016-01-21 09:37 mindplay New Issue
2016-01-21 09:43 mindplay Note Added: 0003430
2016-01-21 10:10 mindplay Note Added: 0003431
2016-02-08 21:12 derick Note Added: 0003459
2016-02-08 21:12 derick Status new => resolved
2016-02-08 21:12 derick Resolution open => won't fix
2016-02-08 21:12 derick Assigned To => derick
2018-11-29 14:24 vaxquis Note Added: 0004728
2018-11-29 14:41 derick Note Added: 0004729
2020-03-12 16:49 derick Category Feature/Change request => Tracing