• 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
Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?


  • Subject: Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 29 May 2011 12:43:19 -0700

On May 29, 2011, at 12:20, Jerry Krinock wrote:

> Ah, I get it now.  It's the access to the pointer m_managedObjectContext itself that's the problem.
>
> So, let's look at the subclass init method which invokes -dealloc:
>
> - (id)initWithDocUuid:(NSString*)docUuid {
>    NSManagedObjectContext* moc ;
>    moc = [[BkmxBasis sharedBasis] exidsMocForIdentifier:docUuid] ;
>
>    self = [super initWithManagedObjectContext:moc
>                                    entityName:constEntityNameStarxid] ;
>    if (!self) {
>        [super dealloc] ;
>    }
>
>    return self ;
> }
>
> It seems that either that recommendation is bad, or I misintepreted how to do it.  What's wrong with that init method?

Actually, I think you misinterpreted how to do it. Remember that 'self' and 'super' are the same object, and you would never write:

	if (!self)
		[self someMethod];

OTOH, if you *did* write that, it ought to be harmless because messaging to 'nil' is harmless. So this *ought* to be harmless too:

	if (!self)
		[super someMethod];

but you seem to have proved it isn't.

The difference in the second case is that the compiler translates it (AFAIK) into a call to objc_msgSendSuper instead of objc_msgSend. What I'm winding up to here is that the failure in messaging a nil 'super' looks to me like a bug in the ObjC runtime's implementation of objc_msgSendSuper.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Follow-Ups:
    • Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
      • From: Ken Thomases <email@hidden>
References: 
 >How can logging a pointer value cause EXC_BAD_ACCESS? (From: Jerry Krinock <email@hidden>)
 >Re: How can logging a pointer value cause EXC_BAD_ACCESS? (From: "Stephen J. Butler" <email@hidden>)
 >Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
  • Next by Date: Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
  • Previous by thread: Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
  • Next by thread: Re: [super dealloc] when init fails. Was: Logging pointer EXC_BAD_ACCESS?
  • Index(es):
    • Date
    • Thread