php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80742 Opcache JIT makes some boolean logic unexpectedly be true
Submitted: 2021-02-13 00:47 UTC Modified: 2021-02-16 11:10 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:5 (100.0%)
From: dktapps at pmmp dot io Assigned: dmitry (profile)
Status: Closed Package: JIT
PHP Version: 8.0Git-2021-02-13 (Git) OS: Windows 10
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:
35 + 32 = ?
Subscribe to this entry?

 
 [2021-02-13 00:47 UTC] dktapps at pmmp dot io
Description:
------------
JIT breaks some boolean logic involving `and` in ways I don't understand.

It's possible this occurs with other operators, but I stumbled on this in code in the wild so I haven't tested further.

When running the following using -dopcache.jit=0 (or without opcache), the script produces the expected result.

Using -dopcache.jit=1205 produces the broken result.

This occurs in a minimal NTS build with only PHP and OPcache using https://github.com/php/php-src/commit/6ec25f386ff058b5ecda6f11c5f62e934b31f660, so it's easily reproducible.



Test script:
---------------
<?php

function checkGroundState(float $movY, float $dy) : void{
	var_dump($movY != $dy, $movY < 0, ($movY != $dy and $movY < 0));
	var_dump("wow!");
}

checkGroundState(0, 0);

Expected result:
----------------
bool(false)
bool(false)
bool(false)
string(4) "wow!"


Actual result:
--------------
bool(false)
bool(false)
bool(true)
string(4) "wow!"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-16 11:10 UTC] nikic@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: dmitry
 [2021-02-16 17:02 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=fad87a24daa8a79f7bcb9d4088f7d96d6f405cac
Log: Fixed bug #80742 (Opcache JIT makes some boolean logic unexpectedly be true)
 [2021-02-16 17:02 UTC] dmitry@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC