• 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
Thread-related crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Thread-related crash


  • Subject: Thread-related crash
  • From: John Stiles <email@hidden>
  • Date: Wed, 7 Apr 2004 14:24:51 -0700

A tester recently found a crash in my app which nobody has been able to reproduce. It looks thread-related, and I don't know where to begin debugging it. (Particularly because it's only been seen one time!) Oddly enough, none of my code appears in the thread's stacks, so I'm a bit stuck for where to begin hunting for the problem. My app does use two threads, and the spawned-off thread needs to update a progress bar, but I am trying very hard to do all Cocoa/GUI-related things via performOnMainThread. I cut out a few of the OS-spawned threads that were sitting idle (i.e. the CoreAudio thread).

Date/Time: 2004-04-02 15:47:57 -0800
OS Version: 10.3.3 (Build 7F44)
Report Version: 2

PID: 722
Thread: 2

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x0000004c

Thread 0:
0 libSystem.B.dylib 0x90017048 semaphore_wait_signal_trap + 0x8
1 libSystem.B.dylib 0x9000e890 _pthread_cond_wait + 0x270
2 com.apple.AppKit 0x92dca4e4 -[NSViewHierarchyLock lockForWriting] + 0x194
3 com.apple.AppKit 0x92dd4dc8 -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 0x114
4 com.apple.AppKit 0x92dedd5c -[NSView displayIfNeeded] + 0xa8
5 com.apple.AppKit 0x92dfea34 -[NSWindow displayIfNeeded] + 0xb4
6 com.apple.AppKit 0x92ddf13c _handleWindowNeedsDisplay + 0xe0
7 com.apple.CoreFoundation 0x90191d60 __CFRunLoopDoObservers + 0x194
8 com.apple.CoreFoundation 0x901915fc __CFRunLoopRun + 0x18c
9 com.apple.CoreFoundation 0x90195f4c CFRunLoopRunSpecific + 0x148
10 com.apple.HIToolbox 0x927d648c RunCurrentEventLoopInMode + 0xac
11 com.apple.HIToolbox 0x927dcb6c ReceiveNextEventCommon + 0xf4
12 com.apple.HIToolbox 0x927feccc BlockUntilNextEventMatchingListInMode + 0x60
13 com.apple.AppKit 0x92dd2a34 _DPSNextEvent + 0x180
14 com.apple.AppKit 0x92de93b0 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 0x74
15 com.apple.AppKit 0x92dfd718 -[NSApplication run] + 0x21c
16 com.apple.AppKit 0x92eb9b80 NSApplicationMain + 0x1d0
17 com.blizzard.installer 0x00004460 main + 0x40
18 com.blizzard.installer 0x00004370 _start + 0x188
19 com.blizzard.installer 0x000041e4 __code_start__ + 0x30

Thread 2 Crashed:
0 com.apple.AppKit 0x92dc4cfc -[NSView lockFocusIfCanDraw] + 0x2a4
1 com.apple.AppKit 0x92de9988 -[NSView lockFocus] + 0x28
2 com.apple.AppKit 0x92e21a50 -[NSUIHeartBeat lockFocusForView:inRect:needsTranslation:] + 0x224
3 com.apple.AppKit 0x92e167d0 -[NSButtonCell(NSDefaultButtonIndicatorPrivate) heartBeat:] + 0x264
4 com.apple.AppKit 0x92e3c078 -[NSWindow(NSWindow_Theme) heartBeat:] + 0xcc
5 com.apple.AppKit 0x92dca9a8 -[NSUIHeartBeat _heartBeatThread:] + 0x25c
6 com.apple.Foundation 0x90a3a2c4 forkThreadForFunction + 0x6c
7 libSystem.B.dylib 0x900247e8 _pthread_body + 0x28

Has anyone seen something like this before??
Here's how I spawn off the second thread.

static App *s_installer;

- (void) awakeFromNib
{
s_app = self;
}

- (void) beginThread:(NSData*)nsData
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

ThreadData data;
[nsData getBytes:&data];

data.callback( data.userData );

[pool release];
}

void InstallerBeginThread( ThreadCallback callback, void *userData )
{
ThreadData data = { callback, userData };
[NSThread detachNewThreadSelector:@selector(beginThread:) toTarget:s_app withObject:[NSData dataWithBytes:&data length:sizeof(ThreadData)]];
}

Here's how I make callbacks to Cocoa on the second thread.

void UpdateProgress( float amount )
{
[s_app performSelectorOnMainThread:@selector(progressSheetUpdateBar:) withObject:[NSNumber numberWithFloat:amount] waitUntilDone:NO];
}

void SetProgressMessage( const char *message )
{
[s_app performSelectorOnMainThread:@selector(progressSheetSetMessage:) withObject:[NSString stringWithUTF8String:message] waitUntilDone:NO];
}


To me this stuff looks pretty darn basic. What am I missing? Is it possible that the autorelease withObject: objects are getting released before the selector has been called? That's all I can think of...??
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Thread-related crash
      • From: Darkshadow <email@hidden>
    • Re: Thread-related crash
      • From: Terrence Asselin <email@hidden>
    • Re: Thread-related crash
      • From: Nat! <email@hidden>
    • Re: Thread-related crash
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: Re: Drawer Edges Change
  • Next by Date: Re: Finding an disabling particular calls in an application?
  • Previous by thread: Re: Finding an disabling particular calls in an application?
  • Next by thread: Re: Thread-related crash
  • Index(es):
    • Date
    • Thread