php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77224 Stack Trace shows wrong parameter value
Submitted: 2018-11-30 09:45 UTC Modified: 2018-12-06 09:38 UTC
From: fkruidhof at mailbox dot org Assigned:
Status: Closed Package: Testing related
PHP Version: 7.2.12 OS: MacOs Mojave
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 + 19 = ?
Subscribe to this entry?

 
 [2018-11-30 09:45 UTC] fkruidhof at mailbox dot org
Description:
------------
The stack trace from an exception shows the wrong value of the parameter that was passed to a function if it's value is changed inside that function (before the exception is thrown).

First bug report, novice PHP developer. Apologies if I miscategorized this report.

Test script:
---------------
<?php
$variable = 'foo';
one($variable);

function one($variable)
{
    try {
        two($variable);
    } catch (Exception $e) {
        echo $e->getTraceAsString();
    }
}

function two($variable)
{
    $variable = 'bar';
    throw new Exception('problem');
}

Expected result:
----------------
Stack trace output:
#0 /file.php(8): two('foo')
#1 /file.php(3): one('foo')
#2 {main}

Actual result:
--------------
Stack trace output:
#0 /file.php(8): two('bar')
#1 /file.php(3): one('foo')
#2 {main}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-30 09:52 UTC] nikic@php.net
This is one of the unfortunate changes resulting from optimizations in PHP 7. It's noted in the PHP 7 migration guide here: https://secure.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified

It's a known issue, but as far as I'm aware there is no work towards improving this (if it can be improved).
 [2018-12-06 09:38 UTC] fkruidhof at mailbox dot org
-Status: Open +Status: Closed
 [2018-12-06 09:38 UTC] fkruidhof at mailbox dot org
Thank you for your reply.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC