Bug #77310 [Com]: Variable values incorrect when Opcache enabled
| From: | syntax53 at gmail dot com | Date: | Mon, 07 Jan 2019 15:04:32 +0000 |
| Subject: | Bug #77310 [Com]: Variable values incorrect when Opcache enabled | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218832@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77310&edit=1
ID: 77310
Comment by: syntax53 at gmail dot com
Reported by: taylor at laravel dot com
Summary: Variable values incorrect when Opcache enabled
Status: Open
Type: Bug
Package: opcache
Operating System: Multiple
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
@nikic -- thanks! How can we track to see when this has been included in an Release/Candidate?
Previous Comments:
------------------------------------------------------------------------
[2019-01-07 09:08:38] nikic@php.net
@titansoftime And yours as well :) Turned out to be the same problem.
------------------------------------------------------------------------
[2019-01-07 09:06:47] nikic@php.net
@syntax53 Your issue is fixed by https://github.com/php/php-src/commit/6f75890e7b8fee3584ec0fa7bd2017e8e75aea91.
------------------------------------------------------------------------
[2019-01-07 08:27:04] nikic@php.net
@syntax53 @titansoftime Ooops, nevermind what I just said, I tested the wrong PHP build. Both of
your test cases still reproduce on current 7.3. I will take a look.
------------------------------------------------------------------------
[2019-01-07 08:21:14] nikic@php.net
@syntax53: That looks like bug #77257 to me, based on the involvement of switch. I can't
reproduce this issue on current 7.3 tip.
@titansoftime: Can't reproduce that on on current 7.3 tip either, though not sure which bug
would have fixed that one.
------------------------------------------------------------------------
[2019-01-07 03:03:22] titansoftime at gmail dot com
I to have experienced this bug. Happens every time after first page load. Totally broke my games
stat system.
Code works ok on first attempt after ftp upload, get 0's every time afterwards.
OpCache for php 7.2.13 has no issue, only php 7.3 has the issue. Disabling opcache solves the
problem. Using Ubuntu 18.
Test code:
class itest{
function make_user_stats():array{
$stats = array(
'strength' => 0,
'stamina' => 0,
'intellect' => 0,
'spirit' => 0,
'agility' => 0,
'armor' => 0,
'resist' => 0
);
$item_stats = array(
'stam_x' => 0,
'str_x' => 0,
'int_x' => 0,
'agi_x' => 0,
'spirit_x' => 0,
'armor_inc' => 0,
'resist_inc' => 0
);
$count = count($rows = array(
array(
'intellect' => 100,
'stamina' => 200,
'strength' => 30,
'spirit' => 300,
'agility' => 500,
'resist' => 5,
'armor' => 5,
),
array(
'intellect' => 200,
'stamina' => 300,
'strength' => 330,
'spirit' => 40,
'agility' => 100,
'resist' => 10,
'armor' => 5,
),
array(
'intellect' => 250,
'stamina' => 120,
'strength' => 330,
'spirit' => 30,
'agility' => 5,
'resist' => 10,
'armor' => 10,
),
));
foreach( $rows as $row ){
$item_stats['stam_x'] += $row['stamina'];
$item_stats['str_x'] += $row['strength'];
$item_stats['int_x'] += $row['intellect'];
$item_stats['agi_x'] += $row['agility'];
$item_stats['spirit_x'] += $row['spirit'];
$item_stats['armor_inc'] += $row['armor'];
$item_stats['resist_inc'] += $row['resist'];
//var_dump($item_stats);
}
$stats['stamina'] += ceil( ($stats['stamina'] *
($item_stats['stam_x']/100)) ) + $item_stats['stam_x'];
$stats['intellect'] += ceil( ($stats['intellect'] *
($item_stats['int_x']/100)) ) + $item_stats['int_x'];
$stats['strength'] += ceil( ($stats['strength'] *
($item_stats['str_x']/100)) ) + $item_stats['str_x'];
$stats['agility'] += ceil( ($stats['agility'] *
($item_stats['agi_x']/100)) ) + $item_stats['agi_x'];
$stats['spirit'] += ceil( ($stats['spirit'] *
($item_stats['spirit_x']/100)) ) + $item_stats['spirit_x'];
$stats['armor'] += $item_stats['armor_inc'];
$stats['resist'] += $item_stats['resist_inc'];
return $stats;
}
}
$itest = new itest;
$stats = $itest->make_user_stats();
var_dump($stats);
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=77310
--
Edit this bug report at https://bugs.php.net/bug.php?id=77310&edit=1