FROM : Guy English
DATE : Tue Nov 23 20:27:43 2004
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
DATE : Tue Nov 23 20:27:43 2004
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
| Related mails | Author | Date |
|---|---|---|
| Jason Bell | Nov 23, 18:35 | |
| Scott Stevenson | Nov 23, 19:57 | |
| Jason Bell | Nov 23, 20:20 | |
| Guy English | Nov 23, 20:27 |






Cocoa mail archive

