Re: IsBadCodePtr in Cocoa or Unix?
Re: IsBadCodePtr in Cocoa or Unix?
- Subject: Re: IsBadCodePtr in Cocoa or Unix?
- From: Clark Cox <email@hidden>
- Date: Thu, 16 Apr 2009 11:21:46 -0700
On Thu, Apr 16, 2009 at 11:09 AM, Eric Gorr <email@hidden> wrote:
> I was wondering if anyone knows of a Cocoa or Unix based equivalent for this
> window function...?
Not really. And if you're at the point where you're asking whether or
not a pointer is "bad" in production code, you've already failed :)
What problem are you actually trying to solve, perhaps there is a better way.
Even on Windows, the use of that function is discouraged (as indicated
by the documentation that you linked to):
"IsBadXxxPtr should really be called CrashProgramRandomly
Often I'll see code that tries to "protect" against invalid pointer
parameters. This is usually done by calling a function like
IsBadWritePtr. But this is a bad idea. IsBadWritePtr should really be
called CrashProgramRandomly.
The documentation for the IsBadXxxPtr functions presents the technical
reasons why, but I'm going to dig a little deeper. For one thing, if
the "bad pointer" points into a guard page, then probing the memory
will raise a guard page exception. The IsBadXxxPtr function will catch
the exception and return "not a valid pointer". But guard page
exceptions are raised only once. You just blew your one chance..."
> http://msdn.microsoft.com/en-us/library/aa366712(VS.85).aspx
>
> Thanks.
>
> _______________________________________________
>
> 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
>
--
Clark S. Cox III
email@hidden
_______________________________________________
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