Debugging help

What is this VM error telling me? It doesn't contain much info. How do I determine the symbol that it failed to invoke? How do I determine what caused the Stack Overflow?

Connecting to device...
Device Version 0.32.1Device id 0 name "A garmin device"
Shell Version 197132Failed invoking <symbol>
Stack Overflow Error
in compute (/Users/Nick/Software/workspace/OSGrid/source/OSGridView.mc:47)
Stack Overflow Error
Stack Overflow Error
Unexpected Type Error
Unexpected Type Error


Here is part of the code (which compiled without errors/warnings). line 47 is the line with Boo!.

//! Set the label of the data field here.
function initialize() {
label = "OS Grid";
}

//! The given info object contains all the current workout
//! information. Calculate a value and return it in this method.
function compute(info) {

System.println("Boo!");

var latitude;
var longitude;


Is there additional debugging that can be enabled to help me with this?
  • How do you have Toybox.System imported?

    Check the top of your file if it says:
    using Toybox.System as Sys;
    then your code should be
    Sys.println("Boo!");
  • I have:
    using Toybox.WatchUi as Ui;
    using Toybox.System as System;
    using Toybox.Math as Math;
    using Toybox.Lang as Lang;


    I'm guessing that error is being caused somewhere else in the code, but the only reported line is 47, as a stack overflow. Before that there is failed symbol, but I have no way of determining what that is.
  • As you seem to understand, the stack overflow appears to have happened as a result of the call to Sys.println(). The issue probably isn't with the call to Sys.println() itself, but with the code that executed before that and took up a bunch of stack space. If this is the case, I'm guessing your code crashes with the same error, even without the Sys.println() call. Are you calling compute() recursively? Do you have a lot of variables declared in compute() that would use up all of the stack?

    If you're still debugging this, I'd start by commenting out blocks of code starting at the bottom of the function. That should help to figure out where the problem lies.
  • Could I see your entire compute function? The stack on data fields is pretty slim, but from the code snippet I can't tell if the function could cause the overflow or not.

    -Alpha Monkey
  • PM with code sent. Thanks for offer to help.