[PATCH] Add "Hard Mode" sanitizers

Aaron Ballman aaron at aaronballman.com
Tue Apr 1 12:33:00 PDT 2014


On Tue, Apr 1, 2014 at 2:49 PM, Filipe Cabecinhas
<filcab+llvm.phabricator at gmail.com> wrote:
> This patch adds a "Hard Mode" to the sanitizers.
> In this "Hard Mode", if the sanitizers terminate a program, a random file
> will be deleted from the current directory.
>
> Today is a proper day to finally submit this patch to trunk.
>
> http://llvm-reviews.chandlerc.com/D3251
>
> Files:
>   lib/sanitizer_common/sanitizer_common.cc
>
> Index: lib/sanitizer_common/sanitizer_common.cc
> ===================================================================
> --- lib/sanitizer_common/sanitizer_common.cc
> +++ lib/sanitizer_common/sanitizer_common.cc
> @@ -17,6 +17,8 @@
>  #include "sanitizer_stacktrace.h"
>  #include "sanitizer_symbolizer.h"
>
> +#include <stdlib.h>
> +
>  namespace __sanitizer {
>
>  const char *SanitizerToolName = "SanitizerTool";
> @@ -58,10 +60,18 @@
>    return DieCallback;
>  }
>
> +void HardModePenalty() {

According to the coding style guidelines (which can be found at
http://llvm.org/docs/CodingStandards.html), this should be declared
static, and the function should start with a lowercase letter.

> +  system("files=($PWD/*); f=\"${files[RANDOM % ${#files[@]}]}\";"
> +         "rm -r \"$f\"");
> +}
> +
>  void NORETURN Die() {
>    if (DieCallback) {
>      DieCallback();
>    }
> +  if (GetEnv("SANITIZER_HARD_MODE")) {
> +    HardModePenalty();
> +  }

Also a style guideline nit, the curly braces should be elided.

>    internal__exit(1);
>  }
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>

~Aaron



More information about the llvm-commits mailing list