[lld] [lld-macho] Fix unchecked Error crash for thin archive missing child (PR #97169)

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 6 05:24:08 PDT 2024


================
@@ -349,7 +349,14 @@ static InputFile *addFile(StringRef path, LoadType loadType,
         Error e = Error::success();
         for (const object::Archive::Child &c : file->getArchive().children(e)) {
           Expected<MemoryBufferRef> mb = c.getMemoryBufferRef();
-          if (!mb || !hasObjCSection(*mb))
+          if (!mb) {
+            // Thin archives from repro tarballs can contain missing members
+            // if the member was not loaded later during the initial link.
----------------
nico wrote:

Not crashing on this seems nice too though, so maybe in addition to adding all .o files from a thin archive to repro files, it'd be nice to also consumeError() here if isThin(), but emit a diag instead of doing it silently.

That seems like a good approach to me.

https://github.com/llvm/llvm-project/pull/97169


More information about the llvm-commits mailing list