Re: AfxIsValidAddress
Re: AfxIsValidAddress
- Subject: Re: AfxIsValidAddress
- From: Jens Alfke <email@hidden>
- Date: Tue, 14 Jul 2015 10:19:14 -0700
> On Jul 14, 2015, at 10:09 AM, Wim Lewis <email@hidden> wrote:
>
> If you don't know (with enough certainty to omit a call to IsValidAddress) whether a pointer is readable, you certainly don't know whether the data there is what you expect to be there.
Plus, preflighting access this way involves race conditions — the memory could be unmapped by another thread after you preflight but before you actually access it.
There are ways to dereference a random pointer without crashing if it’s unmapped, but they involve using a signal handler to recover from the exception _after_ it happens. (For example, the Go language’s runtime does this to turn null-pointer derefs into Go-level ‘panic’ exceptions.) But writing signal handlers that can recover and unwind the stack is extremely deep magic, almost certainly not the kind of thing you want to try implementing yourself.
—Jens
_______________________________________________
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