Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17375] Android: Parsing invalid json hangs the app and crashes debugger

GitHub Issuen/a
TypeBug
PriorityHigh
StatusOpen
ResolutionUnresolved
Affected Version/sRelease 5.1.1
Fix Version/sRelease 3.3.1
ComponentsAndroid
Labelsandroid, core, defect
ReporterSzymon Tomasz Stefanek
AssigneeAshraf Abu
Created2014-06-14T19:40:15.000+0000
Updated2016-06-30T04:34:26.000+0000

Description

In debug mode, calling JSON.parse() on a piece of invalid json hangs the application and silently terminates the debugging session. A sample code snippet is as simple as:
try {
	var j = JSON.parse("{");
}
catch(e)
{
	Ti.API.info("Exception");
}
No code seems to be executed after the JSON.parse() call. The debugger marks the application as terminated without reporting any error and the app on the device hangs (but does not crash). In Release mode an exception is properly reported and execution of the app continues as expected.

Comments

  1. Szymon Tomasz Stefanek 2014-06-19

    Possibly related to TC-4212
  2. Mauro Parra-Miranda 2014-06-30

    The original reporter of this: [~s.stefanek]. Thanks for your report!
  3. Szymon Tomasz Stefanek 2014-07-23

    Ah... why I'm no longer the reporter of this issue? :D
  4. Mauro Parra-Miranda 2014-07-23

    Hello [~s.stefanek]! Sorry for the hiccup! Our system does that on ALLOY and STUDIO bugs (when moving bugs from TC). [~pinnamuri] can help us and set you as the reporter :D
  5. Wilson Luu 2015-11-30

    I can still reproduce this issue *only with Android* and on current GA stack. *Tested on:* Appcelerator Studio, build: 4.4.0.201511241829 Appc CLI NPM: 4.2.2 Appc CLI Core: 5.1.0 Arrow: 1.3.22 SDK: 5.1.1.GA Node: v4.2.2 OS: El Capitan (10.11.1) Device: Genymotion Emulator (4.4.4) *To reproduce:*

    Copy above code snippet into Alloy's index.js file e.g.:

       function doClick(e) {
           alert($.label.text);
       }
       
       try {
       	var j = JSON.parse("{");
       }
       catch(e)
       {
       	Ti.API.info("Exception");
       }
       
       $.index.open();
       

    Debug your app to an emulator; *do not set any breakpoints*

JSON Source