[compiler-rt] r242651 - asan: fix a test

Hans Wennborg hans at chromium.org
Tue Jul 21 14:43:52 PDT 2015


Do you think we should merge this and r242647 to 3.7? This test fails
for me sometimes on the branch.

On Sun, Jul 19, 2015 at 2:44 PM, Dmitry Vyukov <dvyukov at google.com> wrote:
> Author: dvyukov
> Date: Sun Jul 19 16:44:49 2015
> New Revision: 242651
>
> URL: http://llvm.org/viewvc/llvm-project?rev=242651&view=rev
> Log:
> asan: fix a test
>
> Page size is not necessary 4096.
> Use sysconf to obtain page size.
>
>
> Modified:
>     compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc
>
> Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc?rev=242651&r1=242650&r2=242651&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc (original)
> +++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/signal_segv_handler.cc Sun Jul 19 16:44:49 2015
> @@ -18,24 +18,27 @@
>  #include <signal.h>
>  #include <sys/mman.h>
>  #include <string.h>
> +#include <unistd.h>
>
> +unsigned long page_size;
>  void *guard;
>
>  void handler(int signo, siginfo_t *info, void *uctx) {
> -  mprotect(guard, 4096, PROT_READ | PROT_WRITE);
> +  mprotect(guard, page_size, PROT_READ | PROT_WRITE);
>  }
>
>  int main() {
> +  page_size = sysconf(_SC_PAGESIZE);
>    struct sigaction a, old;
>    memset(&a, 0, sizeof(a));
>    memset(&old, 0, sizeof(old));
>    a.sa_sigaction = handler;
>    a.sa_flags = SA_SIGINFO;
>    sigaction(SIGSEGV, &a, &old);
> -  guard = (char *)mmap(0, 3 * 4096, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0) +
> -          4096;
> +  guard = mmap(0, 3 * page_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
> +  guard = (char*)guard + page_size;  // work around a kernel bug
>    for (int i = 0; i < 1000000; i++) {
> -    mprotect(guard, 4096, PROT_NONE);
> +    mprotect(guard, page_size, PROT_NONE);
>      *(int*)guard = 1;
>    }
>    sigaction(SIGSEGV, &old, 0);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list