Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route:cache fails on fresh laravel setup #52779

Closed
JurianArie opened this issue Sep 13, 2024 · 1 comment · Fixed by #52781
Closed

route:cache fails on fresh laravel setup #52779

JurianArie opened this issue Sep 13, 2024 · 1 comment · Fixed by #52781
Labels

Comments

@JurianArie
Copy link
Contributor

Laravel Version

11.23.4

PHP Version

8.3.11

Database Driver & Version

No response

Description

php artisan route:cache fails on a fresh laravel install with this error:

   Symfony\Component\ErrorHandler\Error\FatalError

  Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes)

  at vendor/laravel/serializable-closure/src/Serializers/Native.php:222
    218▕             if (isset($data[self::ARRAY_RECURSIVE_KEY])) {
    219▕                 return;
    220▕             }
    221▕
  ➜ 222▕             $data[self::ARRAY_RECURSIVE_KEY] = true;
    223▕
    224▕             foreach ($data as $key => &$value) {
    225▕                 if ($key === self::ARRAY_RECURSIVE_KEY) {
    226▕                     continue;

Steps To Reproduce

composer create-project laravel/laravel example-app

php artisan route:cache

@lorenzomar
Copy link

lorenzomar commented Sep 13, 2024

I'm having the exact same issue.

Allowing PHP to use infinite memory, the problem arise because the call stack fills up.

This is the stacktrace

local.ERROR: Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? {"exception":"[object] (Error(code: 0): Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? at /var/www/html/vendor/laravel/serializable-closure/src/Serializers/Native.php:111)
[stacktrace]
#0 [internal function]: Laravel\\SerializableClosure\\Serializers\\Native->__serialize()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(1366): serialize(Object(Laravel\\SerializableClosure\\UnsignedSerializableClosure))
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteCacheCommand.php(64): Illuminate\\Routing\\Route->prepareForSerialization()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\RouteCacheCommand->handle()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(95): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(213): Illuminate\\Container\\Container->call(Array)
#9 /var/www/html/vendor/symfony/console/Command/Command.php(279): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#11 /var/www/html/vendor/symfony/console/Application.php(1047): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#12 /var/www/html/vendor/symfony/console/Application.php(316): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Foundation\\Console\\RouteCacheCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#13 /var/www/html/vendor/symfony/console/Application.php(167): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(197): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1203): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#16 /var/www/html/artisan(13): Illuminate\\Foundation\\Application->handleCommand(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
#17 {main}
"} 

And this is the error dumped on shell:

 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
      Laravel\SerializableClosure\Serializers\Native::__serialize()
      +15 vendor frames 

  17  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

The problem occurs from laravel/framework >= 11.23.0. Using version 11.22.0 everything works correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants