Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If an LP recursion is not allowed, then there may be cases of stack overflow?

Does the exception "Stack Overflow" is only linked to the use of recursion? In what other context we can give this exception?

like image 395
Tom Sarduy Avatar asked Dec 22 '22 12:12

Tom Sarduy


1 Answers

  1. allocating local variables that are too large to fit on the stack, for example an array with a million elements on a 64K stack.
  2. too deep a call stack, even without recursion, if each routine has many local variables. example: a() calls b() calls c()...calls z() calls a1()... calls z99(). Each routines local variable as well as a return address for each function (and maybe a stack smashing protector) stays on the stack, until the stack unwinds as each function exits.
like image 167
Tony BenBrahim Avatar answered Apr 23 '23 01:04

Tony BenBrahim