I have a major game breaking bug caused by a script, and I'm not sure how to fix it.

Discussion in 'RGSSx Script Support' started by Ninjakillzu, Jun 29, 2019.

  1. Ninjakillzu

    Ninjakillzu Veteran Veteran

    Messages:
    112
    Likes Received:
    34
    First Language:
    English
    Primarily Uses:
    RMVXA
    I keep running into "Stack error too deep" every now and then during combat, and my game crashes. It seems to be related to
    Shaz's State Add/Remove Commands https://forums.rpgmakerweb.com/index.php?threads/state-add-remove-commands.18593/, and it may be conflicting with another script. Here is a backtracer output:

    2019-06-29 01:27:21 -0700 >> EXCEPTION CAUGHT <<
    SystemStackError: stack level too deep.
    Backtrace:
    Shaz - State Commands:95

    I'm assuming 95 means Line 95 from the script, so here is the section it's in:
    Code:
      #--------------------------------------------------------------------------
      # * State Remove Commands
      #--------------------------------------------------------------------------
      def state_remove_command(state_id)
        $data_states[state_id].note.split(/[\r\n]/).each do |line|
          case line
          when /onremove:\s*(.*)/i
            eval($1)
          end
        end
      end
    end
    Line 95 is the "eval($1)" part.

    The crashing seems to happen randomly when I use attacks that hit multiple times. I am using a bunch of scripts, so I don't know which one could be causing the issue, if it's compatibility related.
     
    #1
  2. cabfe

    cabfe Cool Cat Veteran

    Messages:
    2,303
    Likes Received:
    2,382
    Location:
    France
    First Language:
    French
    Primarily Uses:
    RMVXA
    I don't know how to fix it, but generally this kind of error happens when a script is calling himself or being called too many times at once.

    Check if you have the same function
    state_remove_command
    somewhere else in your other scripts, to begin with.
     
    #2
    Ninjakillzu likes this.
  3. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,371
    Likes Received:
    4,942
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    The common cause of stack level too deep is when you have duplicated script.
     
    #3
    Ninjakillzu likes this.
  4. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,767
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    stack level too deep means you're caught in an infinite loop, probably by that instruction triggering a definition of something somewhere, that leads back to itself.
    my guess is, that the "on remove" tag is causing the removal of another state, which itself is going through the "on remove" process again.
     
    #4
    Ninjakillzu likes this.
  5. Andar

    Andar Veteran Veteran

    Messages:
    28,419
    Likes Received:
    6,485
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    as stated above this error is not one in the script itself (especially not since Shaz is known to write stable scripts) but something creates a loop inside your code.

    that means either the script is installed twice, or there are two different scripts accessing the same override, or the configuration on what to remove is the cause of the loop.

    I suggest you check all unnamed slots in the script editor if you can't find a duplicate, because it happened a lot of time that people forgot to name the slot after installing a script, then forgot it was already installed and installed it again.

    And I also suggest you follow the link "how to use a script" in my signature to the bughunting section, and use the backtracer to find out where in your scripts that loop is.
     
    #5
    Ninjakillzu likes this.
  6. Ninjakillzu

    Ninjakillzu Veteran Veteran

    Messages:
    112
    Likes Received:
    34
    First Language:
    English
    Primarily Uses:
    RMVXA
    I just checked and there are no duplicate scripts or scripts in the unnamed slots, so it must be one of the other reasons. I'll definitely check out the link in your signature as well.
     
    #6
  7. Andar

    Andar Veteran Veteran

    Messages:
    28,419
    Likes Received:
    6,485
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    in that case you'll need the backtracer to find out which scripts are involved.
     
    #7
  8. Ninjakillzu

    Ninjakillzu Veteran Veteran

    Messages:
    112
    Likes Received:
    34
    First Language:
    English
    Primarily Uses:
    RMVXA
    I got the error to show again after installing the backtracer, and this is in the error log: "Shaz - State Commands: 95 :stack level too deep, SystemStackError". No other information is available. This is what it said in the console as well when the error occurred.
     
    #8
  9. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,767
    Likes Received:
    798
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    comment out the eval line, let the code run as usual and wait for that error again.
    if the eval line is the problem, then it is evaluating something that leads back to itself, so, print it out before that eval happens, and when it happens, you'll see the code it was intended to run.
    Code:
    p $1.to_s
    eval ($1)
    
    if that line has a function call in it that can be remotely tracked back to your code,... voila! that's the culprit.
     
    #9
    Ninjakillzu likes this.

Share This Page