[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Garbage collection causes stack overflow
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 11 Apr 2019 09:48:55 -0300
> Maybe if I had more RAM (like a normal desktop computer), the problem
> wouldn't appear. But is this the way the GC is working? Does it use any
> kind of recursion? Or any large stack buffers?
The GC doen't use any kind of explicit recursion nor large stack
buffers. It is written assuming a restricted stack. But some obscure
behavior may create recursive calls. Is it possible for your allocator
to fail when shrinking a memory block?
Any memory-allocation fail may trigger an "emergency collection".
During a GC cycle (finalizers are out of this story), Lua never
allocates new memory, but it may shrink some structures. If
shrinking fails (what Lua assumes should not happen), the emergency
collection will start a new collection, which will fail again,
creating a recursive loop.
But there may be other scenarios that I am not seeing.
Is it possible to have at least some estimate for the number of function
calls in the stack?