Commit 819d7b56 by Karl Schimpf

Fix the PNaCl translator to lock the dump stream when printing errors.

The previous code did not do this. Also localizes the lock to when the error is actually printed. Note: requires https://codereview.chromium.org/865963002 BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/864383002
parent a086b913
......@@ -165,14 +165,7 @@ public:
NaClBitstreamCursor &Cursor, bool &ErrorStatus)
: NaClBitcodeParser(Cursor), Translator(Translator), Header(Header),
ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0),
NumFunctionBlocks(0), BlockParser(nullptr) {
// Note: This gives the reader uncontrolled access to the dump
// stream, which it can then use without locking. TODO(kschimpf):
// Consider reworking the LLVM side to use e.g. a callback for
// errors.
Ice::OstreamLocker L(Translator.getContext());
setErrStream(Translator.getContext()->getStrDump());
}
NumFunctionBlocks(0), BlockParser(nullptr) {}
~TopLevelParser() override {}
......@@ -437,7 +430,11 @@ private:
bool TopLevelParser::Error(const std::string &Message) {
ErrorStatus = true;
++NumErrors;
Ice::GlobalContext *Context = Translator.getContext();
Ice::OstreamLocker L(Context);
raw_ostream &OldErrStream = setErrStream(Context->getStrDump());
NaClBitcodeParser::Error(Message);
setErrStream(OldErrStream);
if (!Translator.getFlags().AllowErrorRecovery)
report_fatal_error("Unable to continue");
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment