[PATCH] D70507: Fix PR44093: use of stale error stream when linking
Thomas Preud'homme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 13:14:45 PST 2019
thopre created this revision.
thopre added reviewers: blackhole12, grimar, MaskRay, espindola.
Herald added subscribers: aheejin, arichardson, sbc100, emaste.
Herald added a project: LLVM.
llvm::lld::link() calls llvm::lld::enableColors() before initializing
the streams llvm::lld::stdoutOS and llvm::lld::stderrOS. This is a
problem because enableColors() uses stderrOS indirectly via a call to
lld::errs(). It can lead to random behavior if the lifetime of the
object passed as stderrOS in link() expires before a subsequent
invocation of link().
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D70507
Files:
lld/COFF/Driver.cpp
lld/ELF/Driver.cpp
lld/MinGW/Driver.cpp
lld/lib/Driver/DarwinLdDriver.cpp
lld/wasm/Driver.cpp
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -84,10 +84,10 @@
errorHandler().errorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"-error-limit=0 to see all errors)";
- enableColors(stderrOS.has_colors());
lld::stdoutOS = &stdoutOS;
lld::stderrOS = &stderrOS;
+ enableColors(stderrOS.has_colors());
config = make<Configuration>();
symtab = make<SymbolTable>();
Index: lld/lib/Driver/DarwinLdDriver.cpp
===================================================================
--- lld/lib/Driver/DarwinLdDriver.cpp
+++ lld/lib/Driver/DarwinLdDriver.cpp
@@ -1150,10 +1150,10 @@
"too many errors emitted, stopping now (use "
"'-error-limit 0' to see all errors)";
errorHandler().exitEarly = CanExitEarly;
- enableColors(StderrOS.has_colors());
lld::stdoutOS = &StdoutOS;
lld::stderrOS = &StderrOS;
+ enableColors(StderrOS.has_colors());
MachOLinkingContext ctx;
if (!parse(args, ctx))
Index: lld/MinGW/Driver.cpp
===================================================================
--- lld/MinGW/Driver.cpp
+++ lld/MinGW/Driver.cpp
@@ -161,9 +161,9 @@
// then call coff::link.
bool mingw::link(ArrayRef<const char *> argsArr, bool canExitEarly,
raw_ostream &stdoutOS, raw_ostream &stderrOS) {
- enableColors(stderrOS.has_colors());
lld::stdoutOS = &stdoutOS;
lld::stderrOS = &stderrOS;
+ enableColors(stderrOS.has_colors());
MinGWOptTable parser;
opt::InputArgList args = parser.parse(argsArr.slice(1));
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -82,10 +82,10 @@
"too many errors emitted, stopping now (use "
"-error-limit=0 to see all errors)";
errorHandler().exitEarly = canExitEarly;
- enableColors(stderrOS.has_colors());
lld::stdoutOS = &stdoutOS;
lld::stderrOS = &stderrOS;
+ enableColors(stderrOS.has_colors());
inputSections.clear();
outputSections.clear();
Index: lld/COFF/Driver.cpp
===================================================================
--- lld/COFF/Driver.cpp
+++ lld/COFF/Driver.cpp
@@ -69,10 +69,10 @@
"too many errors emitted, stopping now"
" (use /errorlimit:0 to see all errors)";
errorHandler().exitEarly = canExitEarly;
- enableColors(stderrOS.has_colors());
lld::stdoutOS = &stdoutOS;
lld::stderrOS = &stderrOS;
+ enableColors(stderrOS.has_colors());
config = make<Configuration>();
symtab = make<SymbolTable>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70507.230321.patch
Type: text/x-patch
Size: 2631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191120/67fb5869/attachment.bin>
More information about the llvm-commits
mailing list