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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC