php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81512 Unexpected behavior with arrays and JIT
Submitted: 2021-10-07 13:55 UTC Modified: 2021-10-25 17:15 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: timuradilev at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: JIT
PHP Version: 8.0.11 OS: Ubuntu 20.04.3
Private report: No CVE-ID: None
 [2021-10-07 13:55 UTC] timuradilev at gmail dot com
Description:
------------
We migrated from php 7.4 to 8 and encountered an issue.
In mongodb/mongo-php-library there is the function 'is_pipeline' that checks that the given argument is the correct pipeline. This function started to return false for correct pipelines.

I reduced the function. See the test script section.
To reproduce the behavior run the test script with opcache.enable_cli=1 and opcache.jit=tracing.

Optimization flags 0052 also trigger the issue.
We think it may be due to the "Inline VM handlers" option.

Test script:
---------------
$pipe = [['val1'],['val2'],];

for ($i = 0; $i < 30; ++$i) {
	echo "$i ";
	if (!is_pipeline($pipe)) {
		echo 'ERROR ';
	}
}

function is_pipeline($pipeline): bool {
	foreach ($pipeline as $stage) {
		if (!is_array($stage)) {
			return false; // must never happen
		}

		$stage = (array) $stage;
		reset($stage);
	}

	return true;
}

Expected result:
----------------
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

Actual result:
--------------
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ERROR 22 ERROR 23 ERROR 24 ERROR 25 ERROR 26 ERROR 27 ERROR 28 ERROR 29 ERROR

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-10-07 14:10 UTC] nikic@php.net
I can reproduced on 8.0 but not on 8.1.
 [2021-10-07 14:10 UTC] nikic@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2021-10-07 18:29 UTC] git@php.net
Automatic comment on behalf of dstogov
Revision: https://github.com/php/php-src/commit/b47a48ff80fdade1f7f44b906da27ea18061464b
Log: Fixed bug #81512 (Unexpected behavior with arrays and JIT)
 [2021-10-07 18:29 UTC] git@php.net
-Status: Assigned +Status: Closed
 [2021-10-25 16:41 UTC] s dot pankratoff at gmail dot com
Hello! 

I can't see this fix in 8.0.12 update. Is there any plans to include it in 8.0 branch or it will be only in 8.1?

Thanks!
 [2021-10-25 17:15 UTC] dmitry@php.net
The fix is not included into 8.0.12, but it's committed into PHP-8.0 branch, and should appear in 8.0.13.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 09:03:14 2021 UTC