[php-src] PR #25039: Fix potential infinite recursion in HYBRID/TAILCALL VMs
| From: | morrisonlevi | Date: | Thu, 29 Oct 2026 19:57:58 +0000 |
| Subject: | [php-src] PR #25039: Fix potential infinite recursion in HYBRID/TAILCALL VMs | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40067@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25039
Author: morrisonlevi
If an extension re-arms
EG(vm_interrupt) inside of zend_interrupt_function
(as-in, unconditionally, every time), then on some VM kinds there will be recursion. For the HYBRID
VM this will crash with stack overflow and for TAILCALL this is just regular infinite recursion.
The VM should always make progress. This is a useful testing property (does my interrupt handler
work properly under ASAN for every possible vm interrupt point that was provided?) but it's
also a nice property to protect production against a misbehaving extension.
I've discussed this with @arnaud-lb previously (see his draft #24472) but I wanted to fix it
more generically and backport it to PHP 8.4. The core of the fix is this:
```diff
- ZEND_VM_ENTER();
+ execute_data = EG(current_execute_data);
+ LOAD_OPLINE();
+ ZEND_VM_LEAVE();
```