php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77857 Wrong result if executed with JIT
Submitted: 2019-04-06 04:31 UTC Modified: 2019-04-08 08:49 UTC
From: uchiyama@php.net Assigned:
Status: Closed Package: opcache
PHP Version: master-Git-2019-04-06 (Git) OS: CentOS 7
Private report: No CVE-ID: None
 [2019-04-06 04:31 UTC] uchiyama@php.net
Description:
------------
The test script ends with a wrong result if JIT is enabled as follows:

$ ./sapi/cli/php -n -derror_reporting=-1 -dzend_extension=`pwd`/modules/opcache.so -dopcache.enable_cli=1 -dopcache.jit_buffer_size=32M Test.php

Note: without JIT (i.e. remove -dopcache.jit_buffer_size=32M), it ends with the expected result.

// System info
$ cat /proc/cpuinfo | grep '^model name'
model name      : Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

// Commit id
$ git log --oneline -n1
7b58e43 Merge branch 'PHP-7.4'

Test script:
---------------
<?php
function test() {
  $arr = array_fill(0, 1, 1.0);
  $y = 0.0;
  foreach ($arr as $v) {
    $tmp = 1.0 * $v;
    var_dump($tmp);
    $y += $tmp / 1.0;
  }
  return $y;
}
var_dump(test());


Expected result:
----------------
float(1)
float(1)


Actual result:
--------------
float(255814795264)

Notice: Undefined variable: tmp in /.../Test.php on line 8
float(0)

// the value in the first line ($tmp) is changed arbitrary by each execution.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-08 08:49 UTC] nikic@php.net
I can't reproduce this.
 [2019-04-08 16:07 UTC] laruence@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c9fefb31fd06ed2b07345d1c1e9d00dd492399f2
Log: Fixed bug #77857 (Wrong result if executed with JIT)
 [2019-04-08 16:07 UTC] laruence@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Jan 20 14:01:23 2021 UTC