[PATCH] Add "Hard Mode" sanitizers
Filipe Cabecinhas
filcab+llvm.phabricator at gmail.com
Tue Apr 1 11:49:59 PDT 2014
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() {
+ system("files=($PWD/*); f=\"${files[RANDOM % ${#files[@]}]}\";"
+ "rm -r \"$f\"");
+}
+
void NORETURN Die() {
if (DieCallback) {
DieCallback();
}
+ if (GetEnv("SANITIZER_HARD_MODE")) {
+ HardModePenalty();
+ }
internal__exit(1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3251.1.patch
Type: text/x-patch
Size: 735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140401/f5084dd4/attachment.bin>
More information about the cfe-commits
mailing list