[compiler-rt] r230019 - [ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand

Renato Golin renato.golin at linaro.org
Sat Feb 21 07:34:02 PST 2015


Hi Timur,

This commit has broken our buildbot:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/3844/steps/ninja%20check%201/logs/AddressSanitizer-arm-linux%3A%3Acontiguous_container_crash.cc

It doesn't seem to be your patch specifically, but it has uncovered an
underlying issue. Can you revert the patch and create a bug, so we can
investigate on the side, please?

thanks,
--renato




On 20 February 2015 at 15:45, Timur Iskhodzhanov <timurrrr at google.com> wrote:
> Author: timurrrr
> Date: Fri Feb 20 09:45:51 2015
> New Revision: 230019
>
> URL: http://llvm.org/viewvc/llvm-project?rev=230019&view=rev
> Log:
> [ASan] Make the argument of '__sanitizer_annotate_contiguous_container' is not aligned error message easier to understand
>
> Modified:
>     compiler-rt/trunk/lib/asan/asan_report.cc
>     compiler-rt/trunk/test/asan/TestCases/contiguous_container_crash.cc
>
> Modified: compiler-rt/trunk/lib/asan/asan_report.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=230019&r1=230018&r2=230019&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_report.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_report.cc Fri Feb 20 09:45:51 2015
> @@ -834,6 +834,8 @@ void ReportBadParamsToAnnotateContiguous
>           "      old_mid : %p\n"
>           "      new_mid : %p\n",
>           beg, end, old_mid, new_mid);
> +  if (!IsAligned(beg, SHADOW_GRANULARITY))
> +    Report("ERROR: beg is not aligned by %d\n", SHADOW_GRANULARITY);
>    stack->Print();
>    ReportErrorSummary("bad-__sanitizer_annotate_contiguous_container", stack);
>  }
>
> Modified: compiler-rt/trunk/test/asan/TestCases/contiguous_container_crash.cc
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/contiguous_container_crash.cc?rev=230019&r1=230018&r2=230019&view=diff
> ==============================================================================
> --- compiler-rt/trunk/test/asan/TestCases/contiguous_container_crash.cc (original)
> +++ compiler-rt/trunk/test/asan/TestCases/contiguous_container_crash.cc Fri Feb 20 09:45:51 2015
> @@ -1,6 +1,7 @@
>  // RUN: %clangxx_asan -O %s -o %t
>  // RUN: not %run %t crash 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
> -// RUN: not %run %t bad-bounds 2>&1 | FileCheck --check-prefix=CHECK-BAD %s
> +// RUN: not %run %t bad-bounds 2>&1 | FileCheck --check-prefix=CHECK-BAD-BOUNDS %s
> +// RUN: not %run %t bad-alignment 2>&1 | FileCheck --check-prefix=CHECK-BAD-ALIGNMENT %s
>  // RUN: env ASAN_OPTIONS=detect_container_overflow=0 %run %t crash
>  //
>  // Test crash due to __sanitizer_annotate_contiguous_container.
> @@ -21,21 +22,31 @@ int TestCrash() {
>    t[60] = 0;
>    __sanitizer_annotate_contiguous_container(&t[0], &t[0] + 100, &t[0] + 100,
>                                              &t[0] + 50);
> +// CHECK-CRASH: AddressSanitizer: container-overflow
>    return (int)t[60 * one];  // Touches the poisoned memory.
>  }
>
>  void BadBounds() {
>    long t[100];
> +// CHECK-BAD-BOUNDS: ERROR: AddressSanitizer: bad parameters to __sanitizer_annotate_contiguous_container
>    __sanitizer_annotate_contiguous_container(&t[0], &t[0] + 100, &t[0] + 101,
>                                              &t[0] + 50);
>  }
>
> +void BadAlignment() {
> +  int t[100];
> +// CHECK-BAD-ALIGNMENT: ERROR: AddressSanitizer: bad parameters to __sanitizer_annotate_contiguous_container
> +// CHECK-BAD-ALIGNMENT: ERROR: beg is not aligned by 8
> +  __sanitizer_annotate_contiguous_container(&t[1], &t[0] + 100, &t[1] + 10,
> +                                            &t[0] + 50);
> +}
> +
>  int main(int argc, char **argv) {
>    assert(argc == 2);
>    if (!strcmp(argv[1], "crash"))
>      return TestCrash();
>    else if (!strcmp(argv[1], "bad-bounds"))
>      BadBounds();
> +  else if (!strcmp(argv[1], "bad-alignment"))
> +    BadAlignment();
>  }
> -// CHECK-CRASH: AddressSanitizer: container-overflow
> -// CHECK-BAD: ERROR: AddressSanitizer: bad parameters to __sanitizer_annotate_contiguous_container
>
>
> _______________________________________________
> 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