Hi, Unsafe "max_execution_time" and "Out of Memory" handling is a huge problem, that often lead to crashes and SHM corruption.
The PoC solves the first problem. https://github.com/php/php-src/pull/1173 Instead of throwing zend_error() from signal handler, now we just set EG(vm_interrupt) and EG(timed_out) flags. PHP VM checks EG(vm_interrupt) flag on each JMPx instruction (potential loop iteration) and then throws the same zend_error() from VM context. This is safe, and we don't need to wrap some critical code sections with HANDLE_BLOCK_INTERRUPTIONS/HANDLE_UNBLOCK_INTERRUPTIONS anymore (we will need them only in opcache). A small overhead of checking EG(vm_interrupt) on jumps is counterbalanced by improvement from HANDLE_BLOCK_INTERRUPTIONS/HANDLE_UNBLOCK_INTERRUPTIONS removal. Unfortunately this approach doesn't support interruption of long-running internal functions yet. It should be extended in some way. May be additional timeout. Improvement ideas are welcome... Also, do we need "safe" handling for other signals? I think no, but may be I miss something. Thanks. Dmitry.