Skip navigation.
 
mlRe: DO crashes when returning NSError by reference
FROM : Charles Srstka
DATE : Sun Apr 08 20:12:06 2007

On Apr 8, 2007, at 9:05 AM, Scotty's Lists wrote:

> Charles,
>
> Sorry, I looked closer at the DRMAASession.m file ref I sent you 
> and it's not the most recent rev in the respository.
>
> This link gives you the most recent (and seemingly fully 
> implemented) version of the class.
>
> <http://code.edbaskerville.com/websvn/filedetails.php?

> repname=XgridDRMAA&path=%2Ftrunk%2Fframework%2Fobjc%
> 2FXgridDRMAASession.m&sc=1>


Thanks. I think I've figured out what the problem was. My initial 
simplification of my code from my original snippet was not entirely 
accurate. What was actually going on was more like this:

- (BOOL)foo:(NSError **)error
{
   // do a bunch of stuff

   BOOL success = [helper bar:error];

   // do a bunch more stuff
}

The problem was that foo: was sometimes getting called with nil for 
the "error" parameter, when the caller didn't care about the error 
message. This got passed on to bar:, which crashed. Apparently, with 
DO you can't pass NULL for values you don't want that are returned by 
reference.

This fixed it:

- (BOOL)foo:(NSError **)error
{
   // do a bunch of stuff

   NSError *theError = nil;
   BOOL success = [helper bar:&theError];

   if(error) *error = theError;

   // do a bunch more stuff
}

Charles

Related mailsAuthorDate
mlDO crashes when returning NSError by reference Charles Srstka Apr 7, 22:05
mlRe: DO crashes when returning NSError by reference Scotty's Lists Apr 8, 16:01
mlRe: DO crashes when returning NSError by reference Charles Srstka Apr 8, 20:12