[php-src] Issue #20973: How to throw an exception in a custom opcode handler?

From: Date: Mon, 19 Jan 2026 05:25:36 +0000
Subject: [php-src] Issue #20973: How to throw an exception in a custom opcode handler?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251568@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20973 Author: matyhtf ### Description Code: https://github.com/swoole/phpy/blob/main/src/php/operator.cc#L319 In the phpy extension, we use opcode handlers to implement operator overloading for Python objects. However, when an exception is thrown in the opcode handler function, it causes a crash. My question is how to safely throw an exception in a custom opcode handler? ```c #define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */ #define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */ #define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */ #define ZEND_USER_OPCODE_ENTER 3 /* enter into new op_array without recursion */ #define ZEND_USER_OPCODE_LEAVE 4 /* return to calling op_array within the same executor */ ``` Which value should be returned? There is no documentation or example code to refer to, so I can only submit an issue.

« previous php.bugs (#251568) next »