Skip to content

Commit 9c8cad5

Browse files
Jlalondroyitaqi
authored andcommitted
[LLDB SEV] Fix free after use of blocks destroyed when the module is replaced
Summary: When auto-load debuginfo replaces a module, the SymbolVendor is also destroyed ``` ObjectFile *obj_file = GetObjectFile(); if (obj_file != nullptr) { LLDB_SCOPED_TIMER(); m_symfile_up.reset( SymbolVendor::FindPlugin(shared_from_this(), feedback_strm)); m_did_load_symfile = true; m_unwind_table.ModuleWasUpdated(); ``` However, StackIDs can already have been created with a SymbolContext whose lifetime is owned by this SymbolVendor ``` dbg.evt-handler Updating Symbol Scope for Stack ID with PC: 0x81e2062 CFA 0x7fa60c5f8ef0to Scope at addr 0x7fede17ca6f0, with Context: , Module{0x564277cfdf60}, CompileUnit{0x000002b0}, Function{0x7fffff00090bd34f}, Block{0x7fffff00090bd41d} ``` Then because the Block has been freed, we would (sometimes!) SEGV when calculating a backtrace. Test Plan: Load the HHVM Core that was causing the SEGV with the new build ``` (lldb) target create --core /tmp/cores/mp726nmh61xkbn9r (lldb) auto-load-debuginfo ... (some omitted waiting) (lldb) target list Current targets: * target #0: /var/tmp/cores/symbol_cache/fbpkg/hphp.admin.compiler_trunk_vm_clang_x86_64_profiled-49de0df41ef10b7389ae62da6ad27bd61702857f/x86_64/buck-out/opt-clang-hhvm-lto/gen/hphp/hhvm/hhvm/hhvm ( arch=x86_64-*-linux, platform=host, pid=2556, state=stopped ) (lldb) bt * thread llvm#1, name = 'hhvm', stop reason = SIGSEGV: sent by tkill system call (sender pid=2556, uid=48) * frame #0: 0x00000000081e2062 hhvm`std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(this=<unavailable>, __r=0x0000000000000038, (null)=<unavailable>) at shared_ptr_base.h:937 frame llvm#1: 0x00000000081e2052 hhvm`std::__shared_ptr<facebook::memcache::mcrouter::CarbonRouterInstance<facebook::tao::proto::TaoProtocolRouterInfo>, (__gnu_cxx::_Lock_policy)2>::__shared_ptr(this=0x00007fa60c5f8e30, __r=0x0000000000000030, (null)=<unavailable>) at shared_ptr_base.h:1409 truncated for brevity ``` Rollback Plan: Reviewers: alexandreperez, satyajanga, gclayton, royshi, selinakim Reviewed By: alexandreperez, satyajanga Subscribers: generatedunixname499725568, #hhvm, #lldb_team Differential Revision: https://phabricator.intern.facebook.com/D79481403 (cherry picked from commit 9ece231250df4980409c69c0c5905d7544290fa5)
1 parent 22fd1da commit 9c8cad5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lldb/source/Core/Module.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,11 @@ void Module::ReplaceObjectFile(Target &target, FileSpec object_file,
12231223
m_object_offset = object_offset;
12241224
lldb::addr_t load_address =
12251225
GetObjectFile()->GetBaseAddress().GetLoadAddress(&target);
1226+
if (m_symfile_up) {
1227+
// Keep all old symbol files around in case there are any lingering type
1228+
// references in any SBValue objects that might have been handed out.
1229+
m_old_symfiles.push_back(std::move(m_symfile_up));
1230+
}
12261231

12271232
// Scope locking.
12281233
{

0 commit comments

Comments
 (0)