Help interpreting crash results.

I managed to capture one of the crashes of my app yesterday, but am none the wiser for it, so am looking for some inspiration.

The CIQ_LOG.txt file reports
ERROR: Unexpected Type Error
DETAILS: Failed invoking <symbol>
STORE_ID: 00000000000000000000000000000000
CALLSTACK:
C:\alan\projects\raceQsGarmin\raceQs\source\engine.mc (sendLogs:905)
C:\alan\projects\raceQsGarmin\raceQs\source\engine.mc (dispData:1101)
C:\alan\projects\raceQsGarmin\raceQs\source\engine.mc (GPSData:808)


sendLogs:905 is here, highlighted in red:
if (logMarksArray.size() > 0){
var replayWptString;
for (var i =0; i< logMarksArray.size(); i++){
replayWptString = "P";
for (var j = 0; j<logMarksArray.size(); j++){[/COLOR]
replayWptString += ","+logMarksArray[j];[/COLOR]
}
replayWptString += ";";
unloadTrackString += replayWptString;
}
logMarksArray = new [0];
}[/CODE]
I don't have the log file for that time as I was in the midst of a race and had to restart the app which then ran fine for another hour (till it crashed again, but that's another story) so the .BAK file got overwritten .

I'm trying to understand what could generate the " Unexpected Type Error" reported on line 905.
If logMarksArraywas anything other than an array, I would get
ERROR: Symbol Not Found Error
DETAILS: Could not find symbol size.


Sometimes the line reference in the error log is refers to the line before the faulty line, so I look at line 906, highlighted blue but can't figure what condition could cause the error.

This code block is executed every 30 seconds, so it's far from being an obscure piece of code that gets executed infrequently, and it only crashed after around 40 minutes of normal running.

Since the crash is intermittent, and I'm not able to replicate it "in the lab", any constructive suggestions for strategies to capture the cause will be greatly appreciated.

Running on VA-HR
  • What if you add an extra check for null or 'instanceof Array' in the loop?

    The only think I can think of is the element not being an array and thus size() failing... Perhaps a null value or something else?
  • FilipStone. I'm thinking the same thing. You'd get this error for "size" if you were trying to use it on an object that didn't do "size()"
  • Ah, no, and that's my point. As I said in my original post:
    If logMarksArraywas anything other than an array, I would get
    ERROR: Symbol Not Found Error
    DETAILS: Could not find symbol size.



    My question is, since an object without a size() method would return the "Could not find symbol size.", what would cause the error that I received:

    DETAILS: Failed invoking <symbol>
  • consider this simple code:
    var num=1;
    var s=num.size();


    The error in the sim is:

    Could not find symbol size.Failed invoking <symbol>Symbol Not Found Error

    Isn't that what your seeing? In this case num is a Number, and Numbers don't do size()change the first line to

    var num=[];

    and no error, as num is now an array, and you can do size() on an array.
  • My question is, since an object without a size() method would return the "Could not find symbol size.", what would cause the error that I received:

    No, you only get the symbol not found error if you are calling a function on an object. If the reference is null, you get the exact error you are concerned about...

    function onStart(state) {

    var logMarksArray = new [2];

    logMarksArray[0] = [ 0, 1, 2 ];
    logMarksArray[1] = null;


    for (var i = 0; i < logMarksArray.size(); ++i) {
    var replayWptString = "P";
    for (var j = 0; j < logMarksArray.size(); ++j) { // line 149
    replayWptString += "," + logMarksArray[j];
    }

    Sys.println(replayWptString);
    }
    }
    [/code]


    Shell Version 0.1.0
    P,0,1,2
    Failed invoking <symbol>
    Unexpected Type Error
    in onStart (Q:\eclipse_stable\workspace\ZZZ\source\ZZZApp.mc:149)
    Connection Finished
    Closing shell and port


    FlipStone is most likely right... you have a bad object reference.
  • Could you elaborate on "bad object reference" please?
    Maybe provide an example so I know what to look for?

    If the logMarksArraywere null, or a number, I think I would have got the "DETAILS: Could not find symbol size." in the log, which I didn't
  • Could you elaborate on "bad object reference" please?

    You have a null in logMarksArray.

    Maybe provide an example so I know what to look for?

    I did. Look at the code above. It shows an array named logMarksArray that is expected to be an array of arrays, and one of the inner arrays is null. You have two options. Find out how the null is making it into your logMarksArray, or avoid accessing the null on the back end.

    If the logMarksArraywere null, or a number, I think I would have got the "DETAILS: Could not find symbol size." in the log, which I didn't
    Well, you think wrong. :) The test code I posted above shows that you get Unexpected Type Error if logMarksArray[ i ] is null. Paste that code into a test project and see what happens.

    Travis
  • Well, you think wrong. :)

    OK, I stand corrected, but learning, sorry:o.
    So the crash would only have been caused my array element logMarksArraybeing null.
    I'll have to work out how once in a blue moon one of my
    logMarksArray.add( lines is adding a null value.
    Thanks everyone.
  • A null is the most likely cause, but I "think" you'd see something similar of it was another object type that didn't handle size()

    If "instanceof" shows something other than an array, log it and bail out of the loop or skip it before you crash...
  • I've tested it on a few and always get "DETAILS: Could not find symbol size", so it seems it's only a null that causes "DETAILS: Failed invoking <symbol>".