Crash when clicking button
This is a crash report I received from a tester, I'm unable to reproduce it myself but it was on 10.9
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Application Specific Information:
objc_msgSend() selector name: checkForPreviouslyShownAlerts
Performing @selector(stopSynchronousPopoverAlert:) from sender NSButton 0x6100001529b0
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff86a8f097 objc_msgSend + 23
1 com.simplexo.SearchYourCloud 0x0000000108073615 0x10803d000 + 222741
2 com.apple.AppKit 0x00007fff8ef5a3d0 -[NSApplication sendAction:to:from:] + 327
3 com.apple.AppKit 0x00007fff8ef5a24e -[NSControl sendAction:to:] + 86
4 com.apple.AppKit 0x00007fff8efa6d7d -[NSCell _sendActionFrom:] + 128
5 com.apple.AppKit 0x00007fff8efc0715 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316
6 com.apple.AppKit 0x00007fff8efbfae7 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
7 com.apple.AppKit 0x00007fff8efbf1fd -[NSControl mouseDown:] + 706
8 com.apple.AppKit 0x00007fff8ef40d08 -[NSWindow sendEvent:] + 11296
9 com.apple.AppKit 0x00007fff8eedf744 -[NSApplication sendEvent:] + 2021
10 com.apple.AppKit 0x00007fff8ed2fa29 -[NSApplication run] + 646
11 com.apple.AppKit 0x00007fff8ed1a803 NSApplicationMain + 940
12 com.simplexo.SearchYourCloud 0x000000010803e704 0x10803d000 + 5892
It appears that the NSAlert is being dereferenced before [self checkForPreviouslyShownAlerts]?
Here is my code, I may put the alert into an iVar to see if it rectifies my user's issue.
NSAlert *noSourcesAlert = [NSAlert alertWithMessageText:NSLocalizedString(@"Title", nil)
defaultButton:NSLocalizedString(@"Yes", nil)
alternateButton:NSLocalizedString(@"No", nil)
otherButton:nil
informativeTextWithFormat:NSLocalizedString(@"Would you like to add your first remote cloud source?", nil)];
[noSourcesAlert setAlertStyle:NSInformationalAlertStyle];
[noSourcesAlert runAsPopoverForView:self.searchField preferredEdge:NSMaxYEdge withCompletionBlock:^(NSInteger result) {
switch (result) {
case NSAlertFirstButtonReturn:
[self executeMethod];
break;
case NSAlertSecondButtonReturn:
default:
break;
}
}];
I get the crash as well in my project. Looking into the cause. Seems to crash when calling "checkForPreviouslyShownAlerts".
just moved the contents of the function "checkForPreviouslyShownAlerts" to the end of "stopSynchronousPopoverAlert" and things seem to be working fine.
Having the same issue here. But @codelance workaround seems to work fine. Thanks for sharing.
It could reproduce in my mac (10.10.4) in debug mode and be resolved the same solution with @codelance .
Does someone explain that?
*** -[NSAlert checkForPreviouslyShownAlerts]: message sent to deallocated instance 0x6080001d8420
(lldb) bt
* thread #1: tid = 0x2427a7c, 0x00007fff82ffad20 CoreFoundation`___forwarding___ + 768, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x00007fff82ffad20 CoreFoundation`___forwarding___ + 768
frame #1: 0x00007fff82ffa998 CoreFoundation`__forwarding_prep_0___ + 120
* frame #2: 0x000000010001421a IPAMan`-[NSAlert(self=0x00006080001d8420, _cmd=0x000000010004f8c0, clickedButton=0x0000608000148c40) stopSynchronousPopoverAlert:] + 426 at NSAlert+Popover.m:93
frame #3: 0x00007fff8d8f3cd7 libsystem_trace.dylib`_os_activity_initiate + 75
frame #4: 0x00007fff89bb6eb1 AppKit`-[NSApplication sendAction:to:from:] + 452
frame #5: 0x00007fff89bcc946 AppKit`-[NSControl sendAction:to:] + 86
frame #6: 0x00007fff89bcc862 AppKit`__26-[NSCell _sendActionFrom:]_block_invoke + 131
frame #7: 0x00007fff8d8f3cd7 libsystem_trace.dylib`_os_activity_initiate + 75
frame #8: 0x00007fff89bcc7bf AppKit`-[NSCell _sendActionFrom:] + 144
frame #9: 0x00007fff8d8f3cd7 libsystem_trace.dylib`_os_activity_initiate + 75
frame #10: 0x00007fff89bcacb3 AppKit`-[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2821
frame #11: 0x00007fff89c2334f AppKit`-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 770
frame #12: 0x00007fff89bc9366 AppKit`-[NSControl mouseDown:] + 714
frame #13: 0x00007fff8a1332dc AppKit`-[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
frame #14: 0x00007fff89ac2c86 AppKit`-[NSWindow sendEvent:] + 470
frame #15: 0x00007fff89abf212 AppKit`-[NSApplication sendEvent:] + 2504
frame #16: 0x00007fff899e8b68 AppKit`-[NSApplication run] + 711
frame #17: 0x00007fff89965244 AppKit`NSApplicationMain + 1832
frame #18: 0x0000000100002f62 IPAMan`main(argc=3, argv=0x00007fff5fbff730) + 34 at main.m:12
frame #19: 0x00007fff86c405c9 libdyld.dylib`start + 1