[compiler-rt] r259741 - [asan] When catching a signal caused by a memory access, print if it's a READ or a WRITE. This touches win/mac files which I have not tested, if a win/mac bot fails I'll try to quick-fix

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 6 17:34:18 PST 2016


On 04 Feb 2016, at 03:02, Kostya Serebryany via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: kcc
> Date: Wed Feb  3 20:02:09 2016
> New Revision: 259741
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259741&view=rev
> Log:
> [asan] When catching a signal caused by a memory access, print if it's a READ or a WRITE. This touches win/mac files which I have not tested, if a win/mac bot fails I'll try to quick-fix
...
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Wed Feb  3 20:02:09 2016
> @@ -1155,6 +1155,11 @@ void *internal_start_thread(void (*func)
> void internal_join_thread(void *th) {}
> #endif
> 
> +bool GetSigContextWriteFlag(void *context) {
> +  ucontext_t *ucontext = (ucontext_t*)context;
> +  return ucontext->uc_mcontext.gregs[REG_ERR] & 2;
> +}
> +

Hi Kostya,

This particular part does not work on FreeBSD (and I guess not on any other BSDs either):

lib/sanitizer_common/sanitizer_linux.cc:1161:32: error: no member named 'gregs' in '__mcontext'
  return ucontext->uc_mcontext.gregs[REG_ERR] & 2;
         ~~~~~~~~~~~~~~~~~~~~~ ^
lib/sanitizer_common/sanitizer_linux.cc:1161:38: error: use of undeclared identifier 'REG_ERR'
  return ucontext->uc_mcontext.gregs[REG_ERR] & 2;
                                     ^

Looking at the code, I think this will be the fix (Ed/Roman, maybe you can sanity check this?):

Index: projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc        (revision 260009)
+++ projects/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc        (working copy)
@@ -1158,7 +1158,11 @@
 bool GetSigContextWriteFlag(void *context) {
 #if defined(__x86_64__) || defined(__i386__)
   ucontext_t *ucontext = (ucontext_t*)context;
+#if SANITIZER_FREEBSD
+  return ucontext->uc_mcontext.mc_err & 2;
+#else
   return ucontext->uc_mcontext.gregs[REG_ERR] & 2;
+#endif
 #else
   return false;  // FIXME: Implement.
 #endif

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160207/ab5d86be/attachment.sig>


More information about the llvm-commits mailing list