mirror of
https://github.com/siemens-mobile-hacks/llvm-c166.git
synced 2026-11-26 06:28:13 +00:00
`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.
|
||
|---|---|---|
| .. | ||
| Address.cpp | ||
| AddressRange.cpp | ||
| AddressRangeListImpl.cpp | ||
| AddressResolver.cpp | ||
| AddressResolverFileLine.cpp | ||
| BugReporter.cpp | ||
| CMakeLists.txt | ||
| Communication.cpp | ||
| CoreProperties.td | ||
| DataFileCache.cpp | ||
| Debugger.cpp | ||
| DebuggerEvents.cpp | ||
| Declaration.cpp | ||
| DemangledNameInfo.cpp | ||
| Diagnostics.cpp | ||
| Disassembler.cpp | ||
| DumpDataExtractor.cpp | ||
| DumpRegisterInfo.cpp | ||
| DumpRegisterValue.cpp | ||
| DynamicLoader.cpp | ||
| EmulateInstruction.cpp | ||
| FileLineResolver.cpp | ||
| FormatEntity.cpp | ||
| Highlighter.cpp | ||
| IOHandler.cpp | ||
| IOHandlerCursesGUI.cpp | ||
| Mangled.cpp | ||
| Module.cpp | ||
| ModuleChild.cpp | ||
| ModuleList.cpp | ||
| Opcode.cpp | ||
| PluginManager.cpp | ||
| Progress.cpp | ||
| ProtocolServer.cpp | ||
| RichManglingContext.cpp | ||
| SafeAutoloadPaths.inc.in | ||
| SearchFilter.cpp | ||
| Section.cpp | ||
| SourceLocationSpec.cpp | ||
| SourceManager.cpp | ||
| Statusline.cpp | ||
| StreamAsynchronousIO.cpp | ||
| Telemetry.cpp | ||
| ThreadedCommunication.cpp | ||
| UserSettingsController.cpp | ||
| Value.cpp | ||