Cocoa exception mechanism and thread safety?
Cocoa exception mechanism and thread safety?
- Subject: Cocoa exception mechanism and thread safety?
- From: Stéphane Sudre <email@hidden>
- Date: Wed, 7 May 2003 11:21:09 +0200
Is the Cocoa exception mechanism thread safe?
I have a method detached in a thread that is using a NSFileHandle
instance and doing a availableData call on it.
(To be complete, let's say the NSFileHandle is obtained from the NSPipe
of a NSTask).
I add exception handling around the availableData call like this:
- (void) waitForInfo:(id) sender
{
NSData *inData=nil;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
while (keepRunning_==YES)
{
NS_DURING
inData =[readHandle_ availableData];
NS_HANDLER
if ([[localException name]
isEqualToString:NSFileHandleOperationException])
{
break;
}
NS_ENDHANDLER
[...]
AFAIK, it should handle the rise of the exception.
Yet, I'm sometimes seeing crashlog like this:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000021
[...]
Thread 6 Crashed:
#0 0x9068ba50 in objc_msgSend
#1 0x908af7d8 in _NSMethodExceptionProem
#2 0x908aec8c in _NSFileHandleRaiseOperationException
#3 0x908464c4 in -[NSConcreteFileHandle availableData]
#4 0x00051f10 in -[TaskController waitForInfo:]
#5 0x9081cd38 in forkThreadForFunction
#6 0x90020d48 in _pthread_body
_______________________________________________
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.