Bug #80745 [Ver->Csd]: JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts

From: Date: Wed, 17 Feb 2021 08:51:58 +0000
Subject: Bug #80745 [Ver->Csd]: JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving bitshifts
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232218@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80745&edit=1

 ID:                 80745
 Updated by:         dmitry@php.net
 Reported by:        dktapps at pmmp dot io
 Summary:            JIT produces Assert failure and UNKNOWN:0 var_dumps
                     in code involving bitshifts
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            JIT
 Operating System:   Linux
 PHP Version:        8.0.2
 Assigned To:        dmitry
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7f68a7afe625ffdc485a05d417197bc30cbb1513
Log: Fixed bug #80745 (JIT produces Assert failure and UNKNOWN:0 var_dumps in code involving
bitshifts)


Previous Comments:
------------------------------------------------------------------------
[2021-02-13 17:39:17] JaxkDev at gmail dot com

Reproduced on windows 10 (10.0.19042.804), PHP 8.0.2 ZTS (opcache.jit=1205)

------------------------------------------------------------------------
[2021-02-13 16:16:09] dktapps at pmmp dot io

Description:
------------
The following code crashes with PHP 8.0.2 ZTS DEBUG when opcache is enabled using opcache.jit=1205.

This happens on both Windows and Linux.

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

final class Message
{
    public $qr = false;

    public $opcode = 0;

    public $aa = false;
}

echo "Starting...\n";

function headerToBinary(Message $message)
{
	$flags = 0;
	$flags = ($flags << 1) | ($message->qr ? 1 : 0);
	$flags = ($flags << 4) | $message->opcode;
	var_dump($flags);
	$flags = ($flags << 1) | ($message->aa ? 1 : 0);
}

headerToBinary(new Message());

echo "PROBLEM NOT REPRODUCED !\n";

Expected result:
----------------
Starting...
int(0)
PROBLEM NOT REPRODUCED !

Actual result:
--------------
In release mode
---------------
Starting...
UNKNOWN:0
PHP Fatal error:  Uncaught TypeError: Unsupported operand types: null << int in
/home/runner/work/php-8-jit-bug-1/php-8-jit-bug-1/reproduce.php:20
Stack trace:
#0 /home/runner/work/php-8-jit-bug-1/php-8-jit-bug-1/reproduce.php(23): headerToBinary()
#1 {main}
  thrown in /home/runner/work/php-8-jit-bug-1/php-8-jit-bug-1/reproduce.php on line 20

In debug mode
-------------
Starting...
UNKNOWN:0
php: /tmp/php-build/source/8.0.2/Zend/zend_operators.c:345: zendi_try_get_long: Assertion `0'
failed.
Aborted (core dumped)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=80745&edit=1


Thread (4 messages)

« previous php.bugs (#232218) next »