From: Evgeniy Stepanov Date: Fri, 6 Jun 2014 12:58:44 +0000 (+0000) Subject: [msan] Better diagnostic for invalid origin id. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9438bf1f620b997c3e7f06226cc7d913429b830f;p=platform%2Fupstream%2Fllvm.git [msan] Better diagnostic for invalid origin id. llvm-svn: 210331 --- diff --git a/compiler-rt/lib/msan/msan.cc b/compiler-rt/lib/msan/msan.cc index 5ee92bf..15714e7d 100644 --- a/compiler-rt/lib/msan/msan.cc +++ b/compiler-rt/lib/msan/msan.cc @@ -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, uptr bp, u32 origin) { 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", diff --git a/compiler-rt/lib/msan/msan_chained_origin_depot.cc b/compiler-rt/lib/msan/msan_chained_origin_depot.cc index a98bcf5..0336a10 100644 --- a/compiler-rt/lib/msan/msan_chained_origin_depot.cc +++ b/compiler-rt/lib/msan/msan_chained_origin_depot.cc @@ -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 { diff --git a/compiler-rt/lib/msan/msan_origin.h b/compiler-rt/lib/msan/msan_origin.h index 64acf1e..a415650 100644 --- a/compiler-rt/lib/msan/msan_origin.h +++ b/compiler-rt/lib/msan/msan_origin.h @@ -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_; diff --git a/compiler-rt/lib/msan/msan_report.cc b/compiler-rt/lib/msan/msan_report.cc index 99ea09c..8a3fd04 100644 --- a/compiler-rt/lib/msan/msan_report.cc +++ b/compiler-rt/lib/msan/msan_report.cc @@ -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);