> On Jul 14, 2015, at 10:09 AM, Wim Lewis <w...@omnigroup.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to