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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fkruidhof at mailbox dot org
New email:
PHP Version: OS:

 

 [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-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 30 01:01:23 2020 UTC