Index: lldb/source/Symbol/SymbolContext.cpp =================================================================== --- lldb/source/Symbol/SymbolContext.cpp +++ lldb/source/Symbol/SymbolContext.cpp @@ -960,8 +960,8 @@ // See if we can find the Module, if so stick it in the SymbolContext. FileSpec module_file_spec(spec_string); ModuleSpec module_spec(module_file_spec); - lldb::ModuleSP module_sp( - m_target_sp->GetImages().FindFirstModule(module_spec)); + lldb::ModuleSP module_sp = m_target_sp ? + m_target_sp->GetImages().FindFirstModule(module_spec) : nullptr; m_type |= eModuleSpecified; if (module_sp) m_module_sp = module_sp; Index: lldb/test/Shell/Commands/command-stop-hook-no-target.test =================================================================== --- /dev/null +++ lldb/test/Shell/Commands/command-stop-hook-no-target.test @@ -0,0 +1,3 @@ +# RUN: %lldb -b -o 'target stop-hook add --name test --shlib test' -o 'bt' | FileCheck %s +# CHECK: Stop hook #1 added +