[proposal] max_execution_time to a negative number

php.internals

Robert Landers

2 years ago
Hello internals, It has come to our attention that max execution time can be set to a negative number, even set_time_limit will happily accept a negative number without error (except when using zend_max_execution_timers in zts mode). I couldn't find, in the docs, how to properly treat a negative number. I think this may need an RFC to codify how negative numbers should be treated. There are three possibilities: 1. Leave it undefined 2. Treat it as zero (unlimited) 3. Fatal error Ideally, we would go with (2) in 8.4 along with a deprecation warning, and then (3) in 9.0. What do you think? Robert Landers Software Engineer Utrecht NL

Kévin Dunglas

2 years ago
According to "man 2 setitimer", the same error should happen on Linux even without zend_max_execution_timer: https://github.com/php/php-src/blob/2079da0158bc91fff4edd85ac66c89b40c4faf3a/Zend/zend_execute_API.c#L1566 A C error will also occur if the value is superior to 999,999,999. We should at least prevent the C error in such cases. I proposed a patch normalizing these values to 0: https://github.com/php/php-src/pull/13942 It's still better than the current situation, and can still be considered as "undefined" until the RFC is voted.