ERA - Unhandled Exception?

It would be very helpful to debugging if the nature of the "Unhandled exception" was also provided in the error report in ERA:

Error Name: Unhandled Exception
Occurrences: 1
First Occurrence: 2020-06-25
Last Occurrence: 2020-06-25
Devices:
    fēnix® 5X / tactix® Charlie: 19.10
App Versions: Beta 3.8.7
Languages: eng
Backtrace:
    Engine.recalcTWDfromPosFlag:1218
    Engine.checkForATackOrJibe:1284
    Engine.doRacingStuff:642
    Engine.dispData:593
    Engine.GPSData:1678

is useful to locate the issue in the code, but just what is triggering the error on line 1218? 

TWD = normalizeHeading(grooveCOG  -180 + jibeAngle/2); 

Yes, it's a (very) intermittent error and no, I can't repro in the lab.

  • The Programmers Guide tantalisingly states "You can use the throw keyword to throw an exception" , but I can't find any further documentation on this facility. I tried a variation on your suggestion:

    throw UnexpectedTypeException("Hello Folks", 0, 0);
     

    but it failed to compile. 

     

  • Try something like this:

    throw new Lang.InvalidValueException("settings is null");

  • Interesting... 

    I tried

     

    throw new Lang.UnexpectedTypeException("settings is null 123456",0,0);

    It ran it on the sim and it crashed with

    Error: Unhandled Exception
    Exception: settings is null 123456
    Stack: 

    When I ran it on a device (F5), it crashed with the following error log:

    ---
    Error: Unhandled Exception
    Time: 2020-07-06T11:49:09Z
    Part-Number: 006-B2697-00
    Firmware-Version: '20.00'
    Language-Code: eng
    ConnectIQ-Version: 3.1.8
    Filename: RACEQS
    Appname: raceQs
    Stack: 
      - pc: 0x10006506
        File: /Users/alansmith/Documents/watchApp/raceQs/source/Engine.mc
        Line: 416
        Function: dispData
      - pc: 0x1000a682
        File: /Users/alansmith/Documents/watchApp/raceQs/source/Engine.mc
        Line: 1687
        Function: GPSData 
    

    No evidence of the supplied text: "settings is null 123456"

    I also tried:

    throw new Lang.InvalidValueException("here's some data");

    it crashed and logged:

    ---
    Error: Unhandled Exception
    Time: 2020-07-06T11:58:56Z
    Part-Number: 006-B2697-00
    Firmware-Version: '20.00'
    Language-Code: eng
    ConnectIQ-Version: 3.1.8
    Filename: RACEQS
    Appname: raceQs
    Stack: 
      - pc: 0x100064fc
        File: /Users/alansmith/Documents/watchApp/raceQs/source/Engine.mc
        Line: 416
        Function: dispData
      - pc: 0x1000a678
    

    Once again no embedded text in the log report.

    So, I'm learning stuff, but still don't see any evidence of being able to bundle user data in the error log. 

    Interestingly also, neither of the crashes showed up in ERA.

  • You're app need to be in the store to show up in ERA.  Based on the file name and the lack of a store ID, these are sideloads.  Also, you get a nice stack trace as it was a sideload that includes debug symbols ("build a release version" was unchecked in the "build for device wizard")

  • I challenge you to “extend exception” here! 

    Challenge accepted.

    using Toybox.Lang;
    class BobTheDangerousKnave extends Lang.Exception {
    	var _sensitiveData;
    	function initialize(sensitiveData) {
    		_sensitiveData = sensitiveData;
    	}
    	function getErrorMessage() {
    		return _sensitiveData;
    	}
    }
    
    // Example:
    throw new BobTheDangerousKnave("My bank details, address and recipe for Lemon Chicken.");
    
    // Console output:
    Error: Unhandled Exception
    Exception: My bank details, address and recipe for Lemon Chicken.
    Stack:

  • He sees it on the console (as you do) but not in the ciq_log (on an actual device)

  • Obviously. But the challenge was to a different part of the question.

  • But the challenge was to a different part of the question.

    Good solution, you do indeed have a good handle on the development environment.

    But the challenge was in the context of a GDPR violation occurring as the result of providing the same level of diagnostics in ERA as in the log file (not the console), and as pointed out, your extension still doesn't write the sensitive data to the log file so really isn't a demonstration of the security risk.

     

  • -

    You will never be able to exfiltrate user data via the exception message because we do not write the exception message to CIQ_LOG.yml. Yes, we write the data to the <APPNAME>.txt log file, and we write it to the Eclipse console, but we never write it to CIQ_LOG.yml.

    So, rewinding a bit, you do see now that it is possible to get the exception message string in the eclipse console, right? If so, you should understand why we cannot allow this data to leak out of the application via the ERA.

  • the challenge was in the context of a GDPR violation occurring as the result of providing the same level of diagnostics in ERA as in the log file (not the console), and as pointed out, your extension still doesn't write the sensitive data to the log file so really isn't a demonstration of the security risk.

    I can write sensitive information to the <APPNAME>.txt log file very easily.

    System.println(age);
    System.println(averageHeartRate);
    System.println(yourEmailAddress);
    System.println(whereYouSpendYourTuesdayAfternoons);

    A developer can write all kinds of sensitive data to the application log file. There is no GDPR concern because we provide no way to get that log file off of the device without the users consent (they have to copy the file off the device and provide it to you). Similarly for the eclipse console, there is potentially sensitive data in there, but it is your data, and exposing your data to you isn't really a security problem.

    The CIQ_LOG.yml situation is very different. We put restrictions on the data that is written to this file because everything in that file is automatically uploaded to Garmin and is viewable by the developer. If we allowed the developer to control the data put into that file, that system could be abused that to get access to the sensitive data without the user's knowledge.