[PATCH] D63042: [LLD][COFF] Fix missing MergeChunk::Instances cleanup in COFF::link()
Erik McClure via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 7 20:34:26 PDT 2019
blackhole12 created this revision.
blackhole12 added a reviewer: lld.
blackhole12 added a project: lld.
Herald added a project: LLVM.
When calling `COFF::link()` with `CanExitEarly` set to `false`, the function needs to clean up several global variable caches to ensure that the next invocation of the function starts from a clean slate. The `MergeChunk::Instances` cache is missing from this cleanup code, and as a result will create nondeterministic memory access errors and sometimes infinite loops due to invalid memory being referenced on the next call to `COFF::link()`.
This fix simply calls `MergeChunk::Instances.clear()` before exiting the function.
An additional review of the COFF library was made to try and find any other missing global caches, but I was unable to find any other than `MergeChunk`. Someone more familiar with the global variables might want to do their own check.
This fix was made to support inNative <https://github.com/innative-sdk/innative>'s `.wast` script compiler, which must build multiple incremental builds. It relies on statically linking LLD because the entire compiler must be a single statically embeddable library, thus preventing it from being able to call LLD as a new process.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D63042
Files:
COFF/Driver.cpp
Index: COFF/Driver.cpp
===================================================================
--- COFF/Driver.cpp
+++ COFF/Driver.cpp
@@ -80,6 +80,7 @@
ObjFile::Instances.clear();
ImportFile::Instances.clear();
BitcodeFile::Instances.clear();
+ MergeChunk::Instances.clear();
return !errorCount();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63042.203666.patch
Type: text/x-patch
Size: 313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190608/7c5e7044/attachment.bin>
More information about the llvm-commits
mailing list