Re: test if a pointer is pointing to a valid object or not?
Re: test if a pointer is pointing to a valid object or not?
- Subject: Re: test if a pointer is pointing to a valid object or not?
- From: "Alastair J.Houghton" <email@hidden>
- Date: Wed, 29 Oct 2003 14:57:56 +0000
On Wednesday, October 29, 2003, at 02:37 pm, p3consulting wrote:
>
And of course if you really try to fake it with an address on
>
something you will build by hand you may be successfull
>
but at least we have something the original poster may use and its
>
program will stop crashing and he can log to try to find out where
>
its object pointer was "corrupted"
From what Ben wrote, I didn't get the impression that he was trying to
debug his application. I think he was trying to find a way to avoid
having to know whether he'd released an object or not.
>
Note the printed values regarding the comment about the possibility of
>
some heaps being allocated out of the [uninitialized static
>
data;bottom of stack] range
I never said they'd be out of that range. What I did say is that
threads' stacks could be allocated within that range, which would
confuse your test into thinking that they were part of the heap
(clearly, they are not). The same goes for mmap()'d files and other
memory mapped resources.
>
and yes, of course continuity of allocated heaps is not guaranted
So you need to use signal handlers or OS calls to avoid a crash, as I
said.
>
So isa looping is no more necessary unless you want to check ObjC
>
runtime structures more deeply (to track down a corruption, a
>
thrid-part framework behavior, )
Certainly it's better with NSZombieEnabled set to YES (as in the code
you posted), but once you've done that, there's hardly any point in the
extra code. OK, your function will tell you that an object isn't valid,
but a crash or an exception will do that for you anyway, and both of
those are easy to debug.
Kind regards,
Alastair.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.