-
July 21st, 2013, 09:29 #1
"C stack overflow" when setting a node value
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:
Code:window.getDatabaseNode().getChild("total_mod_number").setValue(vTotalBonus);
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."A ship in harbor is safe, but that is not what ships are built for." - John Shedd
"Why is it every time we need to get somewhere, I get waylaid by jackassery?" - Dr. Thaddeus Venture
-- CA (Pacific time zone) --
-
July 21st, 2013, 09:32 #2
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?!?
"A ship in harbor is safe, but that is not what ships are built for." - John Shedd
"Why is it every time we need to get somewhere, I get waylaid by jackassery?" - Dr. Thaddeus Venture
-- CA (Pacific time zone) --
-
July 21st, 2013, 09:45 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
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.
Code:local bAllowUpdate = true; function onValueChanged() if bAllowUpdate then bAllowUpdate = false; window.getDatabaseNode().getChild("total_mod_number").setValue(vTotalBonus); bAllowUpdate = true; end end
-
July 21st, 2013, 21:56 #4
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!
"A ship in harbor is safe, but that is not what ships are built for." - John Shedd
"Why is it every time we need to get somewhere, I get waylaid by jackassery?" - Dr. Thaddeus Venture
-- CA (Pacific time zone) --
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks