ART: Fix verifier fail message.
Verifier failure message is corrupted.
The verification failure reason overlaps verification failure location.
MethodVerifier::Fail() method creates failure message stream by
std::ostringstream(failure location) constructor which by default
sets the stream's position indicator to the begging of that stream.
Inserting failure reason to the stream by "<<" then overrides the failure location.
Using std::ostringstream(failure location, std::ostringstream::ate) fixes the issue
by setting the stream's position indicator to the end of the stream on opening.
Change-Id: I8cc1cffc95bc5c56aadbb9ab8c0cdc8bc680d6f4
Signed-off-by: Elena Sayapina <elena.v.sayapina@intel.com>
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index fb57fc7..69627f5 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -499,9 +499,9 @@
}
}
failures_.push_back(error);
- std::string location(StringPrintf("%s: [0x%X]", PrettyMethod(dex_method_idx_, *dex_file_).c_str(),
+ std::string location(StringPrintf("%s: [0x%X] ", PrettyMethod(dex_method_idx_, *dex_file_).c_str(),
work_insn_idx_));
- std::ostringstream* failure_message = new std::ostringstream(location);
+ std::ostringstream* failure_message = new std::ostringstream(location, std::ostringstream::ate);
failure_messages_.push_back(failure_message);
return *failure_message;
}
@@ -516,7 +516,7 @@
DCHECK_NE(failure_num, 0U);
std::ostringstream* last_fail_message = failure_messages_[failure_num - 1];
prepend += last_fail_message->str();
- failure_messages_[failure_num - 1] = new std::ostringstream(prepend);
+ failure_messages_[failure_num - 1] = new std::ostringstream(prepend, std::ostringstream::ate);
delete last_fail_message;
}