I have spin up new ec2 from aws with 1 GB of RAM and 1 vCore with ubuntu 24.04 then I installed PHP and apache2 and composer
The i created new Laravel project and cd into it
And run the following command:
PHP artisan routes:cache
And got the following error:
Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
at vendor/laravel/serializable-closure/src/Serializers/Native.php:111
107▕ * @return array
108▕ */
109▕ public function __serialize()
110▕ {
➜ 111▕ if ($this->scope === null) {
112▕ $this->scope = new ClosureScope();
113▕ $this->scope->toSerialize++;
114▕ }
115▕
1 [internal]:0
LaravelSerializableClosureSerializersNative::__serialize()
+15 vendor frames
17 artisan:13
IlluminateFoundationApplication::handleCommand()
Then I tried with 2 GB of RAM and got the same error.
neazk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
In all your php.ini
files in /etc/php/
subdirectories, add:
zend.max_allowed_stack_size = -1
zend.max_allowed_stack_size
is a new feature in PHP 8.3, which limits the size of the call stack.
-1
means “no limit”.
Of course, this won’t give you infinite memory. It just means PHP won’t limit your stack size. You could still encounter errors, such as a segmentation fault or other process termination (due to running out of memory).
However, it is also possible you have enough memory and it will now work.
If it now works, you should probably set it to an explicit number of bytes (but larger, e.g. 16,678,912). You’ll have to experiment to find the right value.
If it still fails, you’re limited by either your EC2 memory or an OS setting. It is also possible you’re hitting infinite recursion due to a bug.
0