Starfinder Playlist
  1. #1
    dr_venture's Avatar
    Join Date
    Apr 2009
    Location
    Yosemite, CA
    Posts
    1,125

    "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);
    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.
    "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) --

  2. #2
    dr_venture's Avatar
    Join Date
    Apr 2009
    Location
    Yosemite, CA
    Posts
    1,125
    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) --

  3. #3
    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

  4. #4
    dr_venture's Avatar
    Join Date
    Apr 2009
    Location
    Yosemite, CA
    Posts
    1,125
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in