[Lldb-commits] [lldb] Check for null oso SymbolFile in SymbolFileDwarfDebugMap::ResolveSymbolContext (PR #89324)

via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 18 15:10:25 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (jimingham)

<details>
<summary>Changes</summary>

The couple other places that use the oso module's SymbolFile, they check that it's non-null, so this is just an oversight in ResolveSymbolContext.

I didn't add a test for this (but did add a log message for the error case) because I can't see how this would actually happen.  The .o file had to have valid enough DWARF that the linker's parser could handle it or it would not be in the debug map.  If you delete the .o file, we just leave that entry out of the debug map.  If you strip it or otherwise mess with it, we'll notice the changed mod time and refuse to read it...

This was based on a report from the field, and we don't have access to the project.  But if the logging tells me how this happened I can come back and add a test with that example.

---
Full diff: https://github.com/llvm/llvm-project/pull/89324.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (+12-3) 


``````````diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 1de585832e3216..d6560e399e4fc4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -848,9 +848,18 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr,
                 debug_map_entry->data.GetOSOFileAddress();
             Address oso_so_addr;
             if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
-              resolved_flags |=
-                  oso_module->GetSymbolFile()->ResolveSymbolContext(
-                      oso_so_addr, resolve_scope, sc);
+              SymbolFile *sym_file = oso_module->GetSymbolFile();
+              if (sym_file) {
+                resolved_flags |= sym_file->ResolveSymbolContext(oso_so_addr, 
+                    resolve_scope, sc);
+              } else {
+                ObjectFile *obj_file = GetObjectFile();
+                LLDB_LOG(GetLog(DWARFLog::DebugMap),
+                         "Failed to get symfile for OSO: {0} in module: {1}", 
+                         oso_module->GetFileSpec(), 
+                         obj_file ? obj_file->GetFileSpec() : 
+                             FileSpec("unknown"));
+              }
             }
           }
         }

``````````

</details>


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


More information about the lldb-commits mailing list