[PATCH] D128294: [ADT] [lld-macho] Check for end iterator deref in filter_iterator_base

Daniel Bertalan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 11:20:07 PDT 2022


BertalanD created this revision.
BertalanD added reviewers: lld-macho, dblaikie.
Herald added projects: lld-macho, All.
BertalanD requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If ld64.lld was supplied an object file that had a __debug_abbrev or
__debug_str section, but didn't have any compile unit DIEs in
__debug_info, it would dereference an iterator pointing to the empty
array of DIEs. This underlying issue started causing segmentation faults
when parsing for __debug_info was addded in D128184 <https://reviews.llvm.org/D128184>. That commit was
reverted, and this one fixes the invalid dereference to allow relanding
it.

This commit adds an assertion to `filter_iterator_base`'s dereference
operators to catch bugs like this one.

Ran check-llvm, check-clang and check-lld


https://reviews.llvm.org/D128294

Files:
  lld/MachO/InputFiles.cpp
  lld/test/MachO/dwarf-no-compile-unit.yaml
  llvm/include/llvm/ADT/STLExtras.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128294.438772.patch
Type: text/x-patch
Size: 3908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220621/4f31777c/attachment.bin>


More information about the llvm-commits mailing list