forked from OSchip/llvm-project
[msan] Better diagnostic for invalid origin id.
llvm-svn: 210331
This commit is contained in:
parent
b06b15aa28
commit
9438bf1f62
|
@ -197,10 +197,6 @@ void PrintWarning(uptr pc, uptr bp) {
|
||||||
PrintWarningWithOrigin(pc, bp, __msan_origin_tls);
|
PrintWarningWithOrigin(pc, bp, __msan_origin_tls);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OriginIsValid(u32 origin) {
|
|
||||||
return origin != 0 && origin != (u32)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin) {
|
void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin) {
|
||||||
if (msan_expect_umr) {
|
if (msan_expect_umr) {
|
||||||
// Printf("Expected UMR\n");
|
// Printf("Expected UMR\n");
|
||||||
|
@ -214,10 +210,10 @@ void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin) {
|
||||||
GET_FATAL_STACK_TRACE_PC_BP(pc, bp);
|
GET_FATAL_STACK_TRACE_PC_BP(pc, bp);
|
||||||
|
|
||||||
u32 report_origin =
|
u32 report_origin =
|
||||||
(__msan_get_track_origins() && OriginIsValid(origin)) ? origin : 0;
|
(__msan_get_track_origins() && Origin(origin).isValid()) ? origin : 0;
|
||||||
ReportUMR(&stack, report_origin);
|
ReportUMR(&stack, report_origin);
|
||||||
|
|
||||||
if (__msan_get_track_origins() && !OriginIsValid(origin)) {
|
if (__msan_get_track_origins() && !Origin(origin).isValid()) {
|
||||||
Printf(
|
Printf(
|
||||||
" ORIGIN: invalid (%x). Might be a bug in MemorySanitizer origin "
|
" ORIGIN: invalid (%x). Might be a bug in MemorySanitizer origin "
|
||||||
"tracking.\n This could still be a bug in your code, too!\n",
|
"tracking.\n This could still be a bug in your code, too!\n",
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct ChainedOriginDepotDesc {
|
||||||
u32 here_id;
|
u32 here_id;
|
||||||
u32 prev_id;
|
u32 prev_id;
|
||||||
u32 hash() const { return here_id ^ 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 {
|
struct ChainedOriginDepotNode {
|
||||||
|
|
|
@ -66,6 +66,7 @@ class Origin {
|
||||||
u32 raw_id() const { return raw_id_; }
|
u32 raw_id() const { return raw_id_; }
|
||||||
bool isStackRoot() const { return raw_id_ == kStackRoot; }
|
bool isStackRoot() const { return raw_id_ == kStackRoot; }
|
||||||
bool isHeapRoot() const { return raw_id_ == kHeapRoot; }
|
bool isHeapRoot() const { return raw_id_ == kHeapRoot; }
|
||||||
|
bool isValid() const { return raw_id_ != 0 && raw_id_ != (u32)-1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u32 raw_id_;
|
u32 raw_id_;
|
||||||
|
|
|
@ -63,6 +63,10 @@ static void DescribeOrigin(u32 id) {
|
||||||
Decorator d;
|
Decorator d;
|
||||||
while (true) {
|
while (true) {
|
||||||
Origin o(id);
|
Origin o(id);
|
||||||
|
if (!o.isValid()) {
|
||||||
|
Printf(" %sinvalid origin id(%d)%s\n", d.Warning(), id, d.End());
|
||||||
|
break;
|
||||||
|
}
|
||||||
u32 prev_id;
|
u32 prev_id;
|
||||||
u32 stack_id = ChainedOriginDepotGet(o.id(), &prev_id);
|
u32 stack_id = ChainedOriginDepotGet(o.id(), &prev_id);
|
||||||
Origin prev_o(prev_id);
|
Origin prev_o(prev_id);
|
||||||
|
|
Loading…
Reference in New Issue