Can anyone explain this weird crash report I got from a user and symbolized?  
The last thing my code does (frame 24 in the call stack below), is to send 
-[NSAppleScript executeAndReturnError:].  The crash says someone tried to set a 
*dictionary* object with a nil key.  How could I have done that?

OS Version:            Mac OS X 10.10.1 (14B25)
Crashed Thread:        0  Dispatch queue: com.apple.main-thread
Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** setObjectForKey: key cannot be nil'
terminating with uncaught exception of type NSException
abort() called

0   CoreFoundation   __exceptionPreprocess + 172
1   libobjc.A.dylib  objc_exception_throw + 43
2   CoreFoundation   -[__NSDictionaryM setObject:forKey:] + 1174
3   Foundation       __NSThreadPerformPerform + 293
4   CoreFoundation   __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 
+ 17
5   CoreFoundation   __CFRunLoopDoSources0 + 269
6   CoreFoundation   __CFRunLoopRun + 927
7   CoreFoundation   CFRunLoopRunSpecific + 296
8   HIToolbox        RunCurrentEventLoopInMode + 235
9   HIToolbox        GetNextEventMatchingMask + 357
10  HIToolbox        WNEInternal + 149
11  AppleScript      _Z19AEDefaultActiveProcPv + 157
12  AppleScript      _Z23InternalComponentActivej + 81
13  AppleScript      
_ZN15TUASApplication4SendEP25TStackFrame_UASRemoteSendP6AEDescS3_hhh + 2974
14  AppleScript      _Z13UASRemoteSendhhhhhPh + 582
15  AppleScript      _Z11UASExecute1v + 373
16  AppleScript      _Z10UASExecuteh + 193
17  AppleScript      _Z9ASExecutejjiPj + 460
18  AppleScript      AppleScriptComponent + 737
19  AppleScript      _ZN12AGenericCall8DelegateEP23ComponentInstanceRecord + 37
20  AppleScript      _ZN15AGenericManager13HandleOSACallEP19ComponentParameters 
+ 55
21  AppleScript      GenericComponent + 108
22  OpenScripting    OSAExecute + 65
23  Foundation       -[NSAppleScript(NSPrivate) 
_executeWithMode:andReturnError:] + 131
24  MyFramework      -[NSAppleScript(SSYThreadSafe) executeSource:error_p:]

The last frame there, 24, is these three lines of my code:

NSAppleScript* script = [[NSAppleScript alloc] initWithSource:source] ;
NSDictionary* errorDictionary = nil ;
NSAppleEventDescriptor* result = [script 
executeAndReturnError:&errorDictionary] ;

and, down the stack a ways, 'source’ comes from here:

NSString* source ;
source = [NSString stringWithFormat:
                  @"tell application \"%@\"\n"
                  @"activate\n"
                  @"present last logged error\n"
                  @"end tell",
                  [[NSBundle mainAppBundle] bundlePath]
                  ] ;

where [[NSBundle mainAppBundle] bundlePath] returns “com.mycompany.MyApp”.  
MyApp indeed has a 'present last logged error’ AppleScript command defined, and 
it works.

I do not see any bad guys loaded in the Binary Images section.

Although it seems to happen repeatably for this user (3 identical crash 
reports), exercising the same code path on my Mac, the script executes 
perfectly.

* * *

Even if I run code with a crap script source like this:

NSAppleScript* script = [[NSAppleScript alloc] initWithSource:@"garbage in!"] ;
NSDictionary* errorDictionary = nil ;
NSAppleEventDescriptor* result = [script 
executeAndReturnError:&errorDictionary] ;

‘result' is nil, and the errorDictionary tells me politely that my script is 
bad.  It doesn’t crash.

Jerry


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to