llvm-c166/lldb/source/Core
Yao Qi 10fac1c62a
[lldb] Fix null object file deref in ModuleList::AppendImpl (#218448)
`AppendImpl` reads the object file type of the module already at index 0
without checking that it is non-null:

```cpp
const bool elem_zero_is_executable =
    m_modules[0]->GetObjectFile()->GetType() == ObjectFile::Type::eTypeExecutable;
```

A module with no object file can already sit in the list.
`DynamicLoader::LoadBinaryInTarget` appends whatever a symbol locator
finds, without checking that it parses. Appending another module after
such a module makes a member call on that null pointer:

```
lldb/source/Core/ModuleList.cpp:244:42: runtime error: member call on null
pointer of type 'lldb_private::ObjectFile'
```

This PR guards it the same way the next line already guards the incoming
module.

The same search can also leave a null object file behind in
`ObjectFileMachO::LoadCoreFileImages`, fixed in #214634. This PR adds an
`lldb/test/API` regression test that exercises both guards through one
corefile.

## Commits

1. Fix the `AppendImpl` null deref, with a `ModuleListTest` unit test.
2. Add `lldb/test/API/macosx/corefile-unparseable-binary`, which loads a
corefile naming an image that `LLDB_APPLE_DSYMFORUUID_EXECUTABLE`
resolves to a non-object-file, and covers both guards.

## Testing

Reverting the `AppendImpl` guard and running
`ModuleListTest.AppendModuleWithoutObjectFile` under ASan and UBSan
reproduces the runtime error quoted above. Restoring the guard passes
it.
2026-08-24 22:36:20 +01:00
..
Address.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
AddressRange.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
AddressRangeListImpl.cpp
AddressResolver.cpp
AddressResolverFileLine.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
BugReporter.cpp [lldb] Ask the reporter what happened in a bug report (#213173) 2026-07-30 17:59:44 -07:00
CMakeLists.txt [lldb] Ask the reporter what happened in a bug report (#213173) 2026-07-30 17:59:44 -07:00
Communication.cpp
CoreProperties.td [lldb] Collect the executable, symbol file, and core in diagnostics (#210391) 2026-07-17 15:25:27 -05:00
DataFileCache.cpp [lldb] Edits and clarifications to DataFileCache comments, NFC (#199787) 2026-05-27 14:33:54 -07:00
Debugger.cpp [lldb] Use StringRef when creating Listeners (#214863) 2026-08-10 16:27:37 -07:00
DebuggerEvents.cpp
Declaration.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
DemangledNameInfo.cpp
Diagnostics.cpp [lldb] Add an artifact provider mechanism to Diagnostics (#210417) 2026-07-17 16:19:57 -05:00
Disassembler.cpp [lldb] Skip the WebAssembly function header when setting a breakpoint (#211289) 2026-07-23 13:04:34 -05:00
DumpDataExtractor.cpp [lldb] Fix Unicode code point formatting to use proper notation (#211131) 2026-07-22 09:39:02 -07:00
DumpRegisterInfo.cpp [lldb] Convert uses of RegisterTypeFlags into RegisterType (#213886) 2026-08-06 11:02:50 +01:00
DumpRegisterValue.cpp [lldb] Remove ConstString from DumpValueObjectOptions (#215421) 2026-08-12 11:34:14 -07:00
DynamicLoader.cpp [lldb] Consume the located result by rvalue reference (NFC) (#217667) 2026-08-20 15:55:41 +00:00
EmulateInstruction.cpp [lldb] Use Expected in BreakpointLocationPredictor (#197730) 2026-05-15 07:19:51 +00:00
FileLineResolver.cpp [lldb] Remove ConstString getters from FileSpec (#206802) 2026-06-30 14:44:20 -07:00
FormatEntity.cpp [lldb] Rename some register type classes (#213684) 2026-08-05 12:24:19 +01:00
Highlighter.cpp
IOHandler.cpp [lldb][Windows] Check for EOF before the ctrl-c retry in GetLine (#212745) 2026-07-29 16:24:22 +01:00
IOHandlerCursesGUI.cpp [lldb][NFC] Remove various Stream::Printf calls with constants (#210294) 2026-07-20 10:16:42 +01:00
Mangled.cpp [lldb][NFC] Remove various Stream::Printf calls with constants (#210294) 2026-07-20 10:16:42 +01:00
Module.cpp [lldb] Don't overwrite a caller-supplied lookup name (#217491) 2026-08-20 14:40:47 -07:00
ModuleChild.cpp
ModuleList.cpp [lldb] Fix null object file deref in ModuleList::AppendImpl (#218448) 2026-08-24 22:36:20 +01:00
Opcode.cpp
PluginManager.cpp [lldb/script] Add scripting extension template generator (#209647) 2026-07-17 16:21:00 -07:00
Progress.cpp
ProtocolServer.cpp
RichManglingContext.cpp
SafeAutoloadPaths.inc.in
SearchFilter.cpp [lldb][NFC] Remove various Stream::Printf calls with constants (#210294) 2026-07-20 10:16:42 +01:00
Section.cpp [lldb] Add support for Wasm globals (#212516) 2026-07-29 22:07:52 +00:00
SourceLocationSpec.cpp
SourceManager.cpp [lldb][NFC] Remove various Stream::Printf calls with constants (#210294) 2026-07-20 10:16:42 +01:00
Statusline.cpp [lldb] Recompute the statusline on resize without clearing the screen (#202691) 2026-06-15 08:44:50 -07:00
StreamAsynchronousIO.cpp
Telemetry.cpp [lldb] Fix incorrect formatv format strings in logging (#215024) 2026-08-10 10:36:36 -07:00
ThreadedCommunication.cpp
UserSettingsController.cpp [LLDB] Include components of settings paths in apropos search (#194873) 2026-05-18 09:54:14 +01:00
Value.cpp