# [proposal] max_execution_time to a negative number

- Thread: https://externals.io/message/123108
- Original archive: https://news-web.php.net/php.internals/123108
- Started by Robert Landers on 2024-04-11T08:53:20+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #123108 — Robert Landers — 2024-04-11T08:53:20+00:00

URL: https://externals.io/message/123108#123108

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

---

## #123111 — kevin@dunglas.fr — 2024-04-11T14:11:21+00:00

URL: https://externals.io/message/123108#123111 · In reply to: #123108

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.
