• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inexplicable Crash in -[NSAppleScript executeAndReturnError:]


  • Subject: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 23 Jan 2015 11:25:58 -0800

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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
      • From: Ken Thomases <email@hidden>
    • Re: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
      • From: Shane Stanley <email@hidden>
    • Re: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
      • From: Steve Mills <email@hidden>
  • Prev by Date: Re: What's up with the Cocoa Text System?
  • Next by Date: Re: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
  • Previous by thread: Re: Is the button group in Safari a general widget ?
  • Next by thread: Re: Inexplicable Crash in -[NSAppleScript executeAndReturnError:]
  • Index(es):
    • Date
    • Thread