[compiler-rt] r217030 - [msan] Fix origin_history_per_stack_limit=0 behavior.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Sep 3 05:15:59 PDT 2014
Author: eugenis
Date: Wed Sep 3 07:15:59 2014
New Revision: 217030
URL: http://llvm.org/viewvc/llvm-project?rev=217030&view=rev
Log:
[msan] Fix origin_history_per_stack_limit=0 behavior.
It disables the per-stack limit.
Modified:
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/test/msan/chained_origin_limits.cc
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=217030&r1=217029&r2=217030&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Wed Sep 3 07:15:59 2014
@@ -282,14 +282,17 @@ u32 ChainOrigin(u32 id, StackTrace *stac
StackDepotHandle h = StackDepotPut_WithHandle(stack->trace, stack->size);
if (!h.valid()) return id;
- int use_count = h.use_count();
- if (use_count > flags()->origin_history_per_stack_limit)
- return id;
+
+ if (flags()->origin_history_per_stack_limit > 0) {
+ int use_count = h.use_count();
+ if (use_count > flags()->origin_history_per_stack_limit) return id;
+ }
u32 chained_id;
bool inserted = ChainedOriginDepotPut(h.id(), o.id(), &chained_id);
- if (inserted) h.inc_use_count_unsafe();
+ if (inserted && flags()->origin_history_per_stack_limit > 0)
+ h.inc_use_count_unsafe();
return Origin(chained_id, depth).raw_id();
}
Modified: compiler-rt/trunk/test/msan/chained_origin_limits.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/chained_origin_limits.cc?rev=217030&r1=217029&r2=217030&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/chained_origin_limits.cc (original)
+++ compiler-rt/trunk/test/msan/chained_origin_limits.cc Wed Sep 3 07:15:59 2014
@@ -12,6 +12,9 @@
// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
+// RUN: MSAN_OPTIONS=origin_history_size=0,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK-UNLIMITED < %t.out
+
// Stack origin.
// RUN: %clangxx_msan -DSTACK -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t
@@ -24,6 +27,9 @@
// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
+// RUN: MSAN_OPTIONS=origin_history_size=0,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK-UNLIMITED < %t.out
+
// Heap origin, with calls.
// RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t
@@ -37,6 +43,9 @@
// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
+// RUN: MSAN_OPTIONS=origin_history_size=0,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK-UNLIMITED < %t.out
+
// Stack origin, with calls.
// RUN: %clangxx_msan -DSTACK -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t
@@ -50,6 +59,9 @@
// RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
// RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
+// RUN: MSAN_OPTIONS=origin_history_size=0,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=CHECK-UNLIMITED < %t.out
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -143,3 +155,24 @@ int main(void) {
// CHECK-PER-STACK: Uninitialized value was stored to memory at
// CHECK-PER-STACK: in fn1
// CHECK-PER-STACK: Uninitialized value was created
+
+// CHECK-UNLIMITED: WARNING: MemorySanitizer: use-of-uninitialized-value
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was stored to memory at
+// CHECK-UNLIMITED: Uninitialized value was created
More information about the llvm-commits
mailing list