php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80350 zend_set_user_opcode_handler not work
Submitted: 2020-11-12 03:15 UTC Modified: 2020-11-30 19:46 UTC
From: dreamsxin at qq dot com Assigned: dmitry (profile)
Status: Closed Package: JIT
PHP Version: 8.0.0RC3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dreamsxin at qq dot com
New email:
PHP Version: OS:

 

 [2020-11-12 03:15 UTC] dreamsxin at qq dot com
Description:
------------
When enable opcache,
`zend_set_user_opcode_handler(ZEND_INIT_METHOD_CALL, my_method_call_handler);`
will not work.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-12 03:20 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-11-12 03:20 UTC] requinix@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


 [2020-11-12 03:25 UTC] dreamsxin at qq dot com
-Status: Feedback +Status: Open
 [2020-11-12 03:25 UTC] dreamsxin at qq dot com
```c
static int my_method_call_handler(zend_execute_data *execute_data)
{
	zend_printf("hello\n"); // <-- No call
	return ZEND_USER_OPCODE_DISPATCH;
}

static PHP_MINIT_FUNCTION(phalcon)
{
	zend_set_user_opcode_handler(ZEND_INIT_METHOD_CALL, my_method_call_handler);
}
```
```php
$class = "string";
$class->test();
```
php.ini:
```ini
opcache.enable=1
; 启用 Zend OPCache,在 CLI 模式下 
opcache.enable_cli=1
```
no output.
 [2020-11-12 03:40 UTC] danack@php.net
-Status: Open +Status: Feedback
 [2020-11-12 03:40 UTC] danack@php.net
Hi Dreamsxin,

I find it hard to understand this bug report.

I can see you are using an extension with the name Phalcon - but my understanding is that Phalcon itself is not compatible with PHP 8 yet: https://github.com/phalcon/cphalcon/issues/15186

It may be better to talk to the Phalcon people and explain what problem you're having with them, or just wait for Phalcon to support PHP 8.

Otherwise, we would probably need more details of what you are attemting, why you think it should work, and why you think it's a problem to be fixed in PHP.
 [2020-11-12 03:46 UTC] dreamsxin at qq dot com
-Status: Feedback +Status: Open
 [2020-11-12 03:46 UTC] dreamsxin at qq dot com
`run php test.php`

Normally, should be output : hello

Hook `ZEND_INIT_METHOD_CALL`, call `zend_printf("hello\n");`

But, it not work.
 [2020-11-12 03:48 UTC] dreamsxin at qq dot com
Like this extension, https://github.com/nikic/scalar_objects
When disable opcache work fine.
But enable can't work.
 [2020-11-17 09:43 UTC] nikic@php.net
-Assigned To: +Assigned To: dmitry
 [2020-11-17 09:43 UTC] nikic@php.net
@dmitry: I'm wondering whether we should respect user opcode handlers in JIT. It seems like it should be possible, but maybe user opcode handlers break assumptions by type inference etc.
 [2020-11-17 21:41 UTC] dmitry@php.net
-Type: Bug +Type: Feature/Change Request
 [2020-11-17 21:41 UTC] dmitry@php.net
I think we shouldn't support user opcode handlers in JIT.

I don't see a way to handle all possible return values (e.g 
ZEND_USER_OPCODE_DISPATCH) and ability to jump (change EX(opline)).

In general, for each user opcode handler, we may transfer control to interpreter.
 [2020-11-24 13:50 UTC] nikic@php.net
That makes sense. Just not JITing when a user opcode handler is involved seems reasonable.
 [2020-11-30 19:46 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2020-11-30 19:46 UTC] dmitry@php.net
Fixed by d5a82e2c4eebe8337ff7790db46d812af2fbcec9
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 18:01:30 2024 UTC