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

[email protected] (matyhtf)
Newsgroups php.bugs
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.