This is an archive of the discontinued LLVM Phabricator instance.

[sanitizers] read/write page fault detection on mac.
ClosedPublic

Authored by aizatsky on Apr 25 2016, 1:55 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

aizatsky updated this revision to Diff 54899.Apr 25 2016, 1:55 PM
aizatsky retitled this revision from to [sanitizers] read/write page fault detection on mac..
aizatsky updated this object.
aizatsky added a subscriber: llvm-commits.
eugenis accepted this revision.Apr 25 2016, 2:36 PM
eugenis edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 25 2016, 2:36 PM
This revision was automatically updated to reflect the committed changes.
vsk added a subscriber: vsk.Apr 25 2016, 7:21 PM

Hi Mike, some of our internal bots are having an issue with this commit:

error: no member named '__err' in '__darwin_arm_exception_state'
  return ucontext->uc_mcontext->__es.__err & 2 /*T_PF_WRITE*/ ? WRITE : READ;

I'd really appreciate it if you could shed some light on this. I see two definitions of this structure in the OS, and neither contain '__err'. Can you share which OS you built this code against?

Vedant,

I believe it is 10.11 on Intel. This could be CPU difference. I'll try to
add appropriate ifdefs tomorrow.

I'll revert in the meantime. Feel free to reapply with the fix.

For reference from what I see here: http://opensource.apple.com//source/cctools/cctools-836/include/mach/arm/_structs.h this was hitting:

#define _STRUCT_ARM_EXCEPTION_STATE	struct __darwin_arm_exception_state
_STRUCT_ARM_EXCEPTION_STATE
{
	__uint32_t	__exception; /* number of arm exception taken */
	__uint32_t	__fsr; /* Fault status */
	__uint32_t	__far; /* Virtual Fault Address */
};

Is there a kernel source as well for mac on aarch64? I'm trying to determine if illegal write or read has happened. Would be bad to leave aarch out of the implementation.

vsk added a comment.Apr 26 2016, 11:41 AM

Do the xnu sources here help? The latest publicly-available one appears to be xnu-3248.20.55 (http://opensource.apple.com/source/xnu/).

New review with feature enabled only on intel: http://reviews.llvm.org/D19561

I can't find aarch64 support in published xnu sources.

compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc