Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Unified Diff: src/PNaClTranslator.cpp

Issue 864383002: Fix the PNaCl translator to lock the dump stream when printing errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 33dda4b1e593d90ee92d8544dc761a677821fbc0..a1a0cc2bdceb86d00e5e1a47a84f7bdb3f82156d 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698