View Full Version : "C stack overflow" when setting a node value
dr_venture
July 21st, 2013, 09:29
I'm trying to set a node value to a simple integer and getting the error:
Script Error: C stack overflow
Here is the code that is causing the error:
window.getDatabaseNode().getChild("total_mod_number").setValue(vTotalBonus);
I'm still making those noob mistakes (obviously), but I'm using this same syntax in another file and it works perfectly... so I have to assume that this is due to come condition that I'm not aware of.
Is there any documentation on the types of errors that can occur, and what the causes are? And as far as this bug: what type of error is this, and what causes it. A search of the forums and Google found me nothing.
dr_venture
July 21st, 2013, 09:32
Oh, and I should mention the important point that while the above line causes the error (commenting it out makes the error not occur), the line functionally *does work*, and the "total_mod_number" node is correctly set to the value contained in "vTotalBonus"... so works perfectly and throws a stack overflow error. Huh?!?
Moon Wizard
July 21st, 2013, 09:45
The C stack overflow message is an error message from the Lua interpreter. It basically says that you have an endless loop condition that caused the Lua interpreter to make so many function calls that it ran out of memory on the stack to make any more function calls. More than likely, your setValue call triggers an onValueChanged event, which eventually cycles back to running the same line of code. If it's a simple setValue/onValueChanged loop, I think the client catches those right away. However, loops that traverse multiple functions are harder to identify.
The easiest workaround without trying to do any fancy cleanup is to add a gate variable for that script section. Example below.
local bAllowUpdate = true;
function onValueChanged()
if bAllowUpdate then
bAllowUpdate = false;
window.getDatabaseNode().getChild("total_mod_number").setValue(vTotalBonus);
bAllowUpdate = true;
end
end
dr_venture
July 21st, 2013, 21:56
Perfect description - told me just what to look for and allowed me to clear it right up. I would really, really strongly suggest collecting common error conditions, causes, and potential solutions as part of the online documentation. This was a huge help, but I really don't want to compose a message or email to aske questions when I have them, I'd rather just have the docs available to investigate myself. In any case, thanks, moon!
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.