problem
The property exposed on
this
in app.js on iOS,
this.Kroll
, causing errors when you try to do just about anything with it. This forces any inspection of
this
to have special handling code to skip looking at
this.Kroll
. It's also just a little wonky to expose a property on
this
that can catastrophically abort your app if you so much as try to print it. Below are a few scenarios that will cause various errors:
Try to print it
// either line will result in the following error
Ti.API.info(this);
Ti.API.info(this.Kroll);
[DEBUG] 2014-08-02 07:33:37.164 joober[36913:3703] -[KrollContext target]: unrecognized selector sent to instance 0xd12bb00
[ERROR] Script Error {
[ERROR] backtrace = "#0 () at :0";
[ERROR] line = 1;
[ERROR] message = "-[KrollContext target]: unrecognized selector sent to instance 0xd12bb00";
[ERROR] sourceId = 324225728;
[ERROR] sourceURL = "file:///Users/tlukasavage/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/4C55CF1B-BD0A-44A6-9D7E-A3048ACCDC55/joober.app/app.js";
[ERROR] }
try to iterate over its keys
Object.keys(this.Kroll)
[DEBUG] 2014-08-02 07:40:31.403 joober[37262:3703] -[KrollContext target]: unrecognized selector sent to instance 0xd054a10
[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] -[KrollContext target]: unrecognized selector sent to instance 0xd054a10
[ERROR] Stack trace:
[ERROR] 0 CoreFoundation 0x042201c8 __exceptionPreprocess + 152
[ERROR] 1 libobjc.A.dylib 0x03edc8e5 objc_exception_throw + 44
[ERROR] 2 CoreFoundation 0x042bd243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
[ERROR] 3 CoreFoundation 0x0421050b ___forwarding___ + 1019
[ERROR] 4 CoreFoundation 0x042100ee _CF_forwarding_prep_0 + 14
[ERROR] 5 joober 0x00032aeb KrollPropertyNames + 107
[ERROR] 6 joober 0x002b9f2e _ZN2TI16TiCallbackObjectINS_24TiObjectWithGlobalObjectEE19getOwnPropertyNamesEPNS_10TiExcStateERNS_17PropertyNameArrayENS_15EnumerationModeE + 94
[ERROR] 7 joober 0x0036b83a _ZN2TIL21objectConstructorKeysEPNS_10TiExcStateE + 202
[ERROR] 8 joober 0x002fac2a _ZN2TI11Interpreter14privateExecuteENS0_13ExecutionFlagEPNS_12RegisterFileEPNS_10TiExcStateE + 34890
[ERROR] 9 joober 0x002ff71f _ZN2TI11Interpreter7executeEPNS_17ProgramExecutableEPNS_10TiExcStateEPNS_14ScopeChainNodeEPNS_8TiObjectE + 4431
[ERROR] 10 joober 0x00344321 _ZN2TI8evaluateEPNS_10TiExcStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7TiValueE + 337
[ERROR] 11 joober 0x002acce8 TiEvalScript + 344
[ERROR] 12 joober 0x000205bf -[KrollBridge evalFileOnThread:context:] + 1711
[ERROR] 13 libobjc.A.dylib 0x03eee880 -[NSObject performSelector:withObject:withObject:] + 77
[ERROR] 14 joober 0x00028351 -[KrollInvocation invoke:] + 145
[ERROR] 15 joober 0x0002a7d8 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 248
[ERROR] 16 joober 0x0002079d -[KrollBridge evalFile:callback:selector:] + 125
[ERROR] 17 joober 0x000217a2 -[KrollBridge didStartNewContext:] + 2898
[ERROR] 18 libobjc.A.dylib 0x03eee82b -[NSObject performSelector:withObject:] + 70
[ERROR] 19 joober 0x0002b8ab -[KrollContext main] + 3339
[ERROR] 20 Foundation 0x00e11a07 -[NSThread main] + 76
[ERROR] 21 Foundation 0x00e11966 __NSThread__main__ + 1275
[ERROR] 22 libsystem_pthread.dylib 0x04ad45fb _pthread_body + 144
[ERROR] 23 libsystem_pthread.dylib 0x04ad4485 _pthread_struct_init + 0
[ERROR] 24 libsystem_pthread.dylib 0x04ad9cf2 thread_start + 34
[ERROR] 2014-08-02 07:40:31.408 joober[37262:3703] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[KrollContext target]: unrecognized selector sent to instance 0xd054a10'
[ERROR] *** First throw call stack:
[ERROR] (
[ERROR] 0 CoreFoundation 0x042201e4 __exceptionPreprocess + 180
[ERROR] 1 libobjc.A.dylib 0x03edc8e5 objc_exception_throw + 44
[ERROR] 2 CoreFoundation 0x042bd243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
[ERROR] 3 CoreFoundation 0x0421050b ___forwarding___ + 1019
[ERROR] 4 CoreFoundation 0x042100ee _CF_forwarding_prep_0 + 14
[ERROR] 5 joober 0x00032aeb KrollPropertyNames + 107
[ERROR] 6 joober 0x002b9f2e _ZN2TI16TiCallbackObjectINS_24TiObjectWithGlobalObjectEE19getOwnPropertyNamesEPNS_10TiExcStateERNS_17PropertyNameArrayENS_15EnumerationModeE + 94
[ERROR] 7 joober 0x0036b83a _ZN2TIL21objectConstructorKeysEPNS_10TiExcStateE + 202
[ERROR] 8 joober 0x002fac2a _ZN2TI11Interpreter14privateExecuteENS0_13ExecutionFlagEPNS_12RegisterFileEPNS_10TiExcStateE + 34890
[ERROR] 9 joober 0x002ff71f _ZN2TI11Interpreter7executeEPNS_17ProgramExecutableEPNS_10TiExcStateEPNS_14ScopeChainNodeEPNS_8TiObjectE + 4431
[ERROR] 10 joober 0x00344321 _ZN2TI8evaluateEPNS_10TiExcStateEPNS_14ScopeChainNodeERKNS_10SourceCodeENS_7TiValueE + 337
[ERROR] 11 joober 0x002acce8 TiEvalScript + 344
[ERROR] 12 joober 0x000205bf -[KrollBridge evalFileOnThread:context:] + 1711
[ERROR] 13 libobjc.A.dylib 0x03eee880 -[NSObject performSelector:withObject:withObject:] + 77
[ERROR] 14 joober 0x00028351 -[KrollInvocation invoke:] + 145
[ERROR] 15 joober 0x0002a7d8 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 248
[ERROR] 16 joober 0x0002079d -[KrollBridge evalFile:callback:selector:] + 125
[ERROR] 17 joober 0x000217a2 -[KrollBridge didStartNewContext:] + 2898
[ERROR] 18 libobjc.A.dylib 0x03eee82b -[NSObject performSelector:withObject:] + 70
[ERROR] 19 joober 0x0002b8ab -[KrollContext main] + 3339
[ERROR] 20 Foundation 0x00e11a07 -[NSThread main] + 76
[ERROR] 21 Foundation 0x00e11966 __NSThread__main__ + 1275
[ERROR] 22 libsystem_pthread.dylib 0x04ad45fb _pthread_body + 144
[ERROR] 23 libsystem_pthread.dylib 0x04ad4485 _pthread_struct_init + 0
[ERROR] 24 libsystem_pthread.dylib 0x04ad9cf2 thread_start + 34
[ERROR] )
[ERROR] libc++abi.dylib: terminating with uncaught exception of type NSException
trying toString()
this.Kroll.toString()
// you can get it to say "object" though this way:
// Object.prototype.toString.call(this.Kroll)
[DEBUG] 2014-08-02 07:43:40.035 joober[37361:3703] -[KrollContext objectForTiString:context:]: unrecognized selector sent to instance 0xd078b30
[DEBUG] objc[37361]: Method cache corrupted. This may be a message to an invalid object, or a memory error somewhere else.
[DEBUG] objc[37361]: receiver 0x101fc19c, SEL 0xcae53c8, isa 0x103ec128, cache 0x103ec130, buckets 0x10707600, mask 0x0, occupied 0x0
[DEBUG] objc[37361]: receiver 0 bytes, buckets 0 bytes
[DEBUG] objc[37361]: selector 'context'
[DEBUG] objc[37361]: isa '��N'
[DEBUG] objc[37361]: Method cache corrupted.
expected
this.Kroll
should be hidden entirely from
this
(non-enumerable or not exposed altogether), or its inspection should be safe, even if it just returns a basic string for any inspection attempts.
No comments