[compiler-rt] r210331 - [msan] Better diagnostic for invalid origin id.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Jun 6 05:58:44 PDT 2014
Author: eugenis
Date: Fri Jun 6 07:58:44 2014
New Revision: 210331
URL: http://llvm.org/viewvc/llvm-project?rev=210331&view=rev
Log:
[msan] Better diagnostic for invalid origin id.
Modified:
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/msan/msan_chained_origin_depot.cc
compiler-rt/trunk/lib/msan/msan_origin.h
compiler-rt/trunk/lib/msan/msan_report.cc
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=210331&r1=210330&r2=210331&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Fri Jun 6 07:58:44 2014
@@ -197,10 +197,6 @@ void PrintWarning(uptr pc, uptr bp) {
PrintWarningWithOrigin(pc, bp, __msan_origin_tls);
}
-bool OriginIsValid(u32 origin) {
- return origin != 0 && origin != (u32)-1;
-}
-
void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin) {
if (msan_expect_umr) {
// Printf("Expected UMR\n");
@@ -214,10 +210,10 @@ void PrintWarningWithOrigin(uptr pc, upt
GET_FATAL_STACK_TRACE_PC_BP(pc, bp);
u32 report_origin =
- (__msan_get_track_origins() && OriginIsValid(origin)) ? origin : 0;
+ (__msan_get_track_origins() && Origin(origin).isValid()) ? origin : 0;
ReportUMR(&stack, report_origin);
- if (__msan_get_track_origins() && !OriginIsValid(origin)) {
+ if (__msan_get_track_origins() && !Origin(origin).isValid()) {
Printf(
" ORIGIN: invalid (%x). Might be a bug in MemorySanitizer origin "
"tracking.\n This could still be a bug in your code, too!\n",
Modified: compiler-rt/trunk/lib/msan/msan_chained_origin_depot.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_chained_origin_depot.cc?rev=210331&r1=210330&r2=210331&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_chained_origin_depot.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_chained_origin_depot.cc Fri Jun 6 07:58:44 2014
@@ -20,7 +20,7 @@ struct ChainedOriginDepotDesc {
u32 here_id;
u32 prev_id;
u32 hash() const { return here_id ^ prev_id; }
- bool is_valid() { return true; }
+ bool is_valid() { return here_id && prev_id; }
};
struct ChainedOriginDepotNode {
Modified: compiler-rt/trunk/lib/msan/msan_origin.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_origin.h?rev=210331&r1=210330&r2=210331&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_origin.h (original)
+++ compiler-rt/trunk/lib/msan/msan_origin.h Fri Jun 6 07:58:44 2014
@@ -66,6 +66,7 @@ class Origin {
u32 raw_id() const { return raw_id_; }
bool isStackRoot() const { return raw_id_ == kStackRoot; }
bool isHeapRoot() const { return raw_id_ == kHeapRoot; }
+ bool isValid() const { return raw_id_ != 0 && raw_id_ != (u32)-1; }
private:
u32 raw_id_;
Modified: compiler-rt/trunk/lib/msan/msan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_report.cc?rev=210331&r1=210330&r2=210331&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_report.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_report.cc Fri Jun 6 07:58:44 2014
@@ -63,6 +63,10 @@ static void DescribeOrigin(u32 id) {
Decorator d;
while (true) {
Origin o(id);
+ if (!o.isValid()) {
+ Printf(" %sinvalid origin id(%d)%s\n", d.Warning(), id, d.End());
+ break;
+ }
u32 prev_id;
u32 stack_id = ChainedOriginDepotGet(o.id(), &prev_id);
Origin prev_o(prev_id);
More information about the llvm-commits
mailing list