• 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: Crash when creating instance of class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crash when creating instance of class


  • Subject: Re: Crash when creating instance of class
  • From: Guy English <email@hidden>
  • Date: Tue, 23 Nov 2004 14:27:43 -0500

Hi,

I think this:
>         id person = (id)malloc ( sizeof(id) );
>         id alias = person;
>         alias->isa = AIPerson;
>         [alias init];

Is going to crash anyway because you're only allocating enough space
for an object with no ivars. Once you call init AIPerson is going to
stamp all over memory that it doesn't have. I think. :) Haven't looked
at the runtime in ages and I'm not in front of my Mac.

> On Nov 23, 2004, at 9:35 AM, Jason Bell wrote:
> > Exception:  EXC_BAD_ACCESS (0x0001)
> > Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000010

Nutty. :) Can we see the header for the class? The address it's
stamping on makes it look like the malloc is failing, returning NULL
then the init code goes on to write to it anyway and the first var it
tries to write to happens to be at offset 0x00000010. That's my guess
anyway. Now why the malloc is failing I dunno and why the runtime
doesn't check I dunno either. :) But looking that the header could
give us a few hints.

Take care,
Guy
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Crash when creating instance of class (From: Jason Bell <email@hidden>)
 >Re: Crash when creating instance of class (From: Scott Stevenson <email@hidden>)

  • Prev by Date: Re: [SOLVED] Crash when creating instance of class
  • Next by Date: Re: NSAttributedString attribues misbehaving
  • Previous by thread: Re: Crash when creating instance of class
  • Next by thread: Re: [SOLVED] Crash when creating instance of class
  • Index(es):
    • Date
    • Thread