[Lldb-commits] [PATCH] D116772: [lldb] fix memory leak in "GetGDBServerRegisterInfoXMLAndProcess"
Lirong Yuan via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Jan 6 15:32:01 PST 2022
yuanzi created this revision.
yuanzi requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
While running heap checker on a test that uses LLDB API, the following memory leak is found:
RAW: HeapChecker started...
RAW: Leak check _main_ detected leaks of 34 bytes in 4 objects
RAW: The 2 largest leaks:
RAW: Leak of 17 bytes in 2 objects allocated from:
@ 0x7fb93bd20166 NewHook()
@ 0x7fb929372a73 absl::base_internal::MallocHook::InvokeNewHookSlow()
@ 0x5600d1046093 __libc_malloc
@ 0x7fb974529c03 xmlStrdup
@ 0x7fb9744c2a0b xmlGetProp
@ 0x7fb9749d9ed6 lldb_private::XMLNode::GetAttributeValue()
@ 0x7fb979043001 std::__u::__function::__policy_invoker<>::__call_impl<>()
@ 0x7fb9749da06d lldb_private::XMLNode::ForEachChildElement()
@ 0x7fb97903c54d lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess()
@ 0x7fb97902cfe4 lldb_private::process_gdb_remote::ProcessGDBRemote::GetGDBServerRegisterInfo()
@ 0x7fb97902c1d0 lldb_private::process_gdb_remote::ProcessGDBRemote::BuildDynamicRegisterInfo()
@ 0x7fb97902e92a lldb_private::process_gdb_remote::ProcessGDBRemote::SetThreadStopInfo()
@ 0x7fb97902db18 lldb_private::process_gdb_remote::ProcessGDBRemote::DoConnectRemote()
@ 0x7fb97584965e lldb_private::Process::ConnectRemote()
@ 0x7fb975839fa6 lldb_private::Platform::DoConnectProcess()
@ 0x7fb97583a39e lldb_private::Platform::ConnectProcessSynchronous()
@ 0x7fb97545b28b CommandObjectProcessConnect::DoExecute()
@ 0x7fb9755a70c9 lldb_private::CommandObjectParsed::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb975460145 lldb_private::CommandObjectRegexCommand::DoExecute()
@ 0x7fb9755a72d2 lldb_private::CommandObjectRaw::Execute()
@ 0x7fb97559c0e9 lldb_private::CommandInterpreter::HandleCommand()
@ 0x7fb997a5f22e lldb::SBCommandInterpreter::HandleCommand()
@ 0x7fb997a5ef9b lldb::SBCommandInterpreter::HandleCommand()
This change fixes the memory leaks by freeing memory after it is no longer in use.
Tested with `ninja check-lldb`:
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D116772
Files:
lldb/include/lldb/Host/XML.h
lldb/source/Host/common/XML.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116772.398006.patch
Type: text/x-patch
Size: 5071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220106/8a8b88ba/attachment.bin>
More information about the lldb-commits
mailing list