Re: [PHP-DEV] Safe execution timeout handling

2015-03-12 Thread Dan Ackroyd
On 11 March 2015 at 21:44, Dmitry Stogov wrote: > Hi, > > Improvement ideas are welcome... Hi Dmitry, The idea was raised before of having both soft and hard limits for the memory consumption and time limits, and to trigger a user defined callback when the soft limit was reached. This would be

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Stas Malyshev
On Mar 11, 2015 7:01 PM, "Stas Malyshev" wrote: > > Hi! > > > 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 > > JMPs are

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Stas Malyshev
Hi! > 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 JMPs are not the only operations that can transfer control and thus pot

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Dmitry Stogov
On Thu, Mar 12, 2015 at 1:46 AM, Stanislav Malyshev wrote: > Hi! > > > I think, after "max_execution_time" is exceeded, we may start another > > "hard_timeout", and in case the EG(vm_interrupt) wasn't handled > > "safely", kill the process. > > I remember such proposal floating on the list recent

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Stanislav Malyshev
Hi! > I think, after "max_execution_time" is exceeded, we may start another > "hard_timeout", and in case the EG(vm_interrupt) wasn't handled > "safely", kill the process. I remember such proposal floating on the list recently, with two-stage timeouts. But wouldn't killing the process run the sam

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Dmitry Stogov
On Thu, Mar 12, 2015 at 1:23 AM, Stanislav Malyshev wrote: > Hi! > > > 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 >

Re: [PHP-DEV] Safe execution timeout handling

2015-03-11 Thread Stanislav Malyshev
Hi! > 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 That looks very nice but makes timeouts much less powerful. I think wit