Okay, so, I really need to know what can cause this. It’s really really annoying, how does this happen, what is this cause? How do I determine what could be causing it.
A buffer overflow is not an error that is typically reported to the user (they tend to cause crashes instead), so I’m going to assume you are talking about stack overflows. A stack overflow happens when the call stack gets too deep, which, in most cases, is caused by infinite recursion.
function MyFunc() MyFunc() end
The above function will cause a stack overflow, and is easy to spot. However, most of the time it’s not as obvious.
local function MyDrawHook() render.RenderView(myviewtable) end hook.Add("PostDrawOpaqueRenderables", "MyDrawHook", MyDrawHook)
This will also cause a stack overflow, because calling render.RenderView() will invoke a lot of draw hooks, including PostDrawOpaqueRenderables, and will cause infinite recursion. To prevent this, you include some kind of guard.
local drawingworld = false local function MyDrawHook() if not drawingworld then drawingworld = true render.RenderView(myviewtable) drawingworld = false end end hook.Add("PostDrawOpaqueRenderables", "MyDrawHook", MyDrawHook)