Maximum Function nesting level of '100'

Asked

Viewed 1,146 times

1

I’m getting the following error on Laravel (while recovering a password):

Maximum Function nesting level of '100' reached, aborting!

The solution I found was to add this line in autoload.php

ini_set('xdebug.max_nesting_level', 500);

And it all worked out.

But my question is, what is it and why I need to change?

Why does it generate this error?

Thank you

  • Searching the internet for similar solutions I found this: http://stackoverflow.com/questions/8656089/solution-for-fatal-error-maximum-function-nesting-level-of-100-reached-abor. One explanation given is that the Xdebug extension limits the stack to a maximum of 100 pointer stacks. You can increase the amount of stacking or disable in php.ini if you don’t use this extension.

  • But in practice, it means that this request that is giving error, is trying to do what reaches to pass 100?

  • For each function call, the return address is saved on the stack, when the function gives a Return it goes back to the line that the function was called, picking up from the stack the last stored position. But you must possess a function that is calling it several times and exceeding the maximum size of 100 stored memory addresses. You can use an explanation of how a stack (Stack) works based on the C language: http://www.cprogressivo.net/2014/05/Pilhas-Stack-em-C-O-Que-E-Como-Implementar-Tutorial-C-Estrutura-de-Dados.html Assembly also provides a very good explanation.

  • And the solution I found is recommended?

1 answer

1

It is recommended if you cannot change the logic of the function so that it decreases the number of recursions. However, this solution also relies on performance impact analysis and memory consumption of your application/server/infrastructure.

That is to say, before you take this as the ultimate solution, it would be interesting to reevaluate the code at the points where the exception is launched, if actually already optimized, keep the configuration.

But actually using Laravel I have sometimes come across the need to set this configuration at 500, mainly because of extra packages that generate many features with Xdebug on. However, I use this configuration only in development and testing environment, in production I do not keep Xdebug on, which allows me to maintain the standard for recursions.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.