[lld] [lld-macho] Fix unchecked Error crash for thin archive missing child (PR #97169)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 10:00:00 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld
Author: Daniel Bertalan (BertalanD)
<details>
<summary>Changes</summary>
The repro file in #<!-- -->94716 contains a few thin archives without their member object files present. I couldn't figure out why this happened (issue in repro tarball generation?), but this caused an "unhandled Error" crash on `LLVM_ENABLE_ABI_BREAKING_CHECKS` builds.
---
Full diff: https://github.com/llvm/llvm-project/pull/97169.diff
1 Files Affected:
- (modified) lld/MachO/Driver.cpp (+6-1)
``````````diff
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 9dddabcf3680c..eb64e764100b2 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -349,7 +349,12 @@ 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) {
+ llvm::consumeError(mb.takeError());
+ continue;
+ }
+
+ if (!hasObjCSection(*mb))
continue;
if (Error e = file->fetch(c, "-ObjC"))
error(toString(file) + ": -ObjC failed to load archive member: " +
``````````
</details>
https://github.com/llvm/llvm-project/pull/97169
More information about the llvm-commits
mailing list