[php-src] PR #14627: Interrupt while internal frame is on the stack

From: Date: Fri, 21 Jun 2024 18:37:42 +0000
Subject: [php-src] PR #14627: Interrupt while internal frame is on the stack
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-26759@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/14627 Author: morrisonlevi If the EG(vm_interrupt) flag is set, the goal is for zend_interrupt_function to be called while the internal function call frame is still on the stack. The reason that profilers and other tools which set VM interrupts will never get that leaf frame included in the backtrace, which is often important. For instance, regular expression, database, and file I/O functions tend to be internal functions which consume time (whether wall- or cpu-time) and are therefore relevant to a profiler. The obvious work-arounds are undesirable: 1. Setting zend_execute_internal to check it manually while the frame is on the stack will disable certain optimizations, and in PHP 8.4 this becomes worse with frameless calls. This is partly why I'm visiting this now. 2. Observers trigger when the frame is still on the stack but are costly when you want to observe every internal call. It seems to me that triggering the interrupt while the call is still on the frame makes the most sense. Once upon a time, I tried to make this change but I was unable to find the PR and/or discussion around it. I know that someone brought up that it was designed this way for an interrupting scheduler to be able to switch the VM away to another place but: 1. I don't remember details. 2. This was pre-fibers. Interested parties, techniques, and tools may have changed. 3. If the proposed behavior is problematic for someone, then they I think they have to solve it anyway because [zend_call_function has handled interrupts for 4 years](https://github.com/php/php-src/commit/555489dd83132d9c8ba28ad9cde1edf4c5823358). I'm sure such a tool would also have an issue with that case if it has problems with this one. So I'm looking for feedback on my patch: 1. Is this problematic for a use-case of yours? If so, why? 2. Do you see something specifically wrong, such as I don't handle rethrowing exceptions correctly? I know the patch is also incomplete as it only handles ZEND_DO_ICALL. I am waiting for feedback before working on the other call opcodes. And also more generally: 1. Do you see other viable work-arounds? Whether this lands or not, having a better work-around for older versions would be nice to know.

« previous php.git-pulls (#26759) next »