DO crashes when returning NSError by reference
DO crashes when returning NSError by reference
- Subject: DO crashes when returning NSError by reference
- From: Charles Srstka <email@hidden>
- Date: Sat, 7 Apr 2007 15:05:30 -0500
Okay, so I've got a tool that's being accessed via DO. The tool has a
bunch of methods that look like this:
- (BOOL)doSomethingWithSomeObject:(id)someObj error:(out NSError **)
error
{
[self doSomething:someObj];
return someConditionForSuccess;
}
The caller in the client app calls the method like this:
NSError *error = nil;
BOOL success = [helper doSomethingWithSomeObject:someObj error:&error];
and the helper crashes. The client, of course, then throws an
"<NSInvalidReceivePortException> connection went invalid while
waiting for a reply" exception.
According to the crash log, the crash occurs in the helper tool, in -
[NSConcretePortCoder encodeObject:isBycopy:isByref:]. Here's the
backtrace:
Thread 0 Crashed:
0 <<00000000>> 0xfffeff18 objc_msgSend_rtp + 24
1 com.apple.Foundation 0x92bd9ed8 -[NSConcretePortCoder
encodeObject:isBycopy:isByref:] + 164
2 com.apple.Foundation 0x92bd93d8 _NSWalkData + 1128
3 com.apple.Foundation 0x92be0044 -[NSInvocation
encodeReturnValueWithCoder:] + 648
4 com.apple.Foundation 0x92bdfbc0 -[NSConnection
returnResult:exception:sequence:imports:] + 504
5 com.apple.Foundation 0x92bdc8b4 -[NSConnection
handleRequest:sequence:] + 1068
6 com.apple.Foundation 0x92bdc1d8 -[NSConnection
handlePortCoder:] + 496
7 com.apple.Foundation 0x92bdbf44 -[NSConcretePortCoder
dispatch] + 100
8 com.apple.Foundation 0x92bdb924 __NSFireMachPort + 276
9 com.apple.CoreFoundation 0x907ec850 __CFMachPortPerform + 176
10 com.apple.CoreFoundation 0x907ec764 __CFRunLoopDoSource1 + 152
11 com.apple.CoreFoundation 0x907dee7c __CFRunLoopRun + 1556
12 com.apple.CoreFoundation 0x907de4ac CFRunLoopRunSpecific + 268
13 com.apple.Foundation 0x92bf2170 -[NSRunLoop
runMode:beforeDate:] + 172
14 com.apple.Foundation 0x92c36e70 -[NSRunLoop runUntilDate:] + 80
15 <my helper tool> 0x00023e5c main + 460 (SQLHelperMain.m:22)
16 <my helper tool> 0x000021cc 0x1000 + 4556
17 <my helper tool> 0x00001ed0 0x1000 + 3792
The thing is, the crash seems to have something to do with the
NSError object that's being returned by reference. If I delete that
NSError pointer from the arguments so it's just -(BOOL)
doSomethingWithSomeObject:(id)someObj, then it works fine - but I'm
not returning that error by reference like I'd like to. If the
NSError pointer is there in the arguments, though, it crashes. It
doesn't matter whether the helper sets *error to nil or to a
legitimate NSError instance, or doesn't touch it at all - the method
always crashes while trying to return. I've experimented with adding
keywords to the NSError pointer parameter, for instance changing out
to inout, adding a bycopy, etc. Nothing seems to make a difference at
all.
I'm sure I'm making some really brain-dead mistake - can someone
please point out to me what it is?
Thanks,
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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