THE ORB
Starting the studio

stack overflow

A script called itself over and over until it ran out of room. Something is looping into itself.

groupsThat script dies completelycodeNeeds a developer

Do this first

Note which resource it names and stop it — it will keep taking the rest down with it.

bug_reportPaste your whole console instead

What it means

A function called itself, directly or through a chain, until Lua ran out of call stack. The script stops there. On a server this often takes the whole resource down at startup, which is why it shows up as "stack overflow immediately after starting".

What causes it

Ordered by how often it is the answer.

  1. 1

    Direct recursion with no base case

    A function that always calls itself. Rare on purpose, common by accident when two functions were given the same name.

  2. 2

    An event that triggers itself

    A handler for myres:update that calls TriggerEvent('myres:update', ...) inside itself. Each trigger is synchronous, so it recurses.

  3. 3

    A metatable __index that points at itself

    setmetatable(t, { __index = t }). Any missing key recurses forever.

  4. 4

    Two resources triggering each other

    A triggers B's event, B's handler triggers A's. Neither file looks recursive on its own.

  5. 5

    A deep table serialised with a cycle

    json.encode on a table that contains itself.

How to tell which one is yours

The traceback repeats. Look for the same file and line appearing over and over in the frames — that pair is the loop. If the trace is truncated, add a print at the top of the suspect function and watch it fire without end.

Where to look

The repeated frame in the traceback.

How to fix it

Give the recursion a floor, or break the event cycle:

-- an event that must not re-enter itself
local updating = false
AddEventHandler('myres:update', function(data)
    if updating then return end
    updating = true
    -- work
    updating = false
end)

Still stuck on your own code?

This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.

bug_reportOpen Server Fixer

Errors that travel with this one