Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev/wwolff/sanitize 20240305 #78

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

wwolff42
Copy link

@wwolff42 wwolff42 commented Mar 7, 2024

No description provided.

@wwolff42 wwolff42 self-assigned this Mar 7, 2024
A DpuContext, wrapper of backends's `struct dpu_context_t` is constructed for
every LLDB Dpu instance. These instances cover a full rank.

Currently, a DpuContext instance is partialialy initialize at the first StopThreads
call  (i.e. when LLDB stop threads for investigation) on which Dpu is
currently allocated.

When LLDB resume threads with ResumeThreads call, it tries to resume threads from
all LLDB::Dpu instance. Though, this does not correspond to the number of requested Dpus.
Hence, LLDB manipulates unitialized object.

This commit fixes those report from `valgrind`:
```
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x182A1E: lldb_private::dpu::DpuContext::ContextReadyForResumeOrStep() (DpuContext.cpp:153)
==17528==    by 0x180C68: lldb_private::dpu::Dpu::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*, bool) (Dpu.cpp:295)
==17528==    by 0x18069C: lldb_private::dpu::DpuRank::ResumeDpus() (DpuRank.cpp:125)
==17528==    by 0x17DDEB: lldb_private::process_dpu::ProcessDpu::Detach() (ProcessDpu.cpp:460)
==17528==    by 0x17D339: lldb_private::process_dpu::ProcessDpu::Kill() (ProcessDpu.cpp:512)
==17528==    by 0x1A8E70: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_k(StringExtractorGDBRemote&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A904D: std::_Function_handler<lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult (StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()::{lambda(StringExtractorGDBRemote, lldb_private::Status&, bool&, bool&)#1}>::_M_invoke(std::_Any_data const&, StringExtractorGDBRemote&, lldb_priv
ate::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x19839D: lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(lldb_private::Timeout<std::ratio<1l, 1000000l> >, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A8A74: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::DataAvailableCallback() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1598A3: lldb_private::MainLoop::RunImpl::ProcessEvents() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x159CCF: lldb_private::MainLoop::Run() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x180C6F: lldb_private::dpu::Dpu::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*, bool) (Dpu.cpp:295)
==17528==    by 0x18069C: lldb_private::dpu::DpuRank::ResumeDpus() (DpuRank.cpp:125)
==17528==    by 0x17DDEB: lldb_private::process_dpu::ProcessDpu::Detach() (ProcessDpu.cpp:460)
==17528==    by 0x17D339: lldb_private::process_dpu::ProcessDpu::Kill() (ProcessDpu.cpp:512)
==17528==    by 0x1A8E70: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_k(StringExtractorGDBRemote&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A904D: std::_Function_handler<lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult (StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()::{lambda(StringExtractorGDBRemote, lldb_private::Status&, bool&, bool&)#1}>::_M_invoke(std::_Any_data const&, StringExtractorGDBRemote&, lldb_priv
ate::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x19839D: lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(lldb_private::Timeout<std::ratio<1l, 1000000l> >, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A8A74: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::DataAvailableCallback() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1598A3: lldb_private::MainLoop::RunImpl::ProcessEvents() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x159CCF: lldb_private::MainLoop::Run() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x14C220: main_gdbserver(int, char**) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x489E135: ci_debug_teardown_dpu (ufi_debug.c:443)
==17528==    by 0x488B339: dpu_finalize_fault_process_for_dpu (dpu_debug.c:120)
==17528==    by 0x182C1C: lldb_private::dpu::DpuContext::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*) (DpuContext.cpp:120)
==17528==    by 0x180C9B: lldb_private::dpu::Dpu::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*, bool) (Dpu.cpp:308)
==17528==    by 0x18069C: lldb_private::dpu::DpuRank::ResumeDpus() (DpuRank.cpp:125)
==17528==    by 0x17DDEB: lldb_private::process_dpu::ProcessDpu::Detach() (ProcessDpu.cpp:460)
==17528==    by 0x17D339: lldb_private::process_dpu::ProcessDpu::Kill() (ProcessDpu.cpp:512)
==17528==    by 0x1A8E70: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_k(StringExtractorGDBRemote&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A904D: std::_Function_handler<lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult (StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()::{lambda(StringExtractorGDBRemote, lldb_private::Status&, bool&, bool&)#1}>::_M_invoke(std::_Any_data const&, StringExtractorGDBRemote&, lldb_priv
ate::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x19839D: lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(lldb_private::Timeout<std::ratio<1l, 1000000l> >, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A8A74: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::DataAvailableCallback() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x489E140: ci_debug_teardown_dpu (ufi_debug.c:443)
==17528==    by 0x488B339: dpu_finalize_fault_process_for_dpu (dpu_debug.c:120)
==17528==    by 0x182C1C: lldb_private::dpu::DpuContext::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*) (DpuContext.cpp:120)
==17528==    by 0x180C9B: lldb_private::dpu::Dpu::ResumeThreads(llvm::SmallVector<unsigned int, 8u>*, bool) (Dpu.cpp:308)
==17528==    by 0x18069C: lldb_private::dpu::DpuRank::ResumeDpus() (DpuRank.cpp:125)
==17528==    by 0x17DDEB: lldb_private::process_dpu::ProcessDpu::Detach() (ProcessDpu.cpp:460)
==17528==    by 0x17D339: lldb_private::process_dpu::ProcessDpu::Kill() (ProcessDpu.cpp:512)
==17528==    by 0x1A8E70: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_k(StringExtractorGDBRemote&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A904D: std::_Function_handler<lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult (StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&), lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers()::{lambda(StringExtractorGDBRemote, lldb_private::Status&, bool&, bool&)#1}>::_M_invoke(std::_Any_data const&, StringExtractorGDBRemote&, lldb_priv
ate::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x19839D: lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(lldb_private::Timeout<std::ratio<1l, 1000000l> >, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A8A74: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::DataAvailableCallback() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==
```
In internal API, a {bkp, mem, dma}_fault_thread_index are declared as
`dpu_thread_t` a.k.a `uint8_t`. In LLDB::Dpu::GetThreadState, shortcut variables
are declared as `uint32_t`.

This commit synchronize both to fix those report from `valgrind`:

```
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x182126: lldb_private::dpu::Dpu::GetThreadState(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, lldb::StopReason&, bool) (Dpu.cpp:785)
==17528==    by 0x18024D: lldb_private::process_dpu::ThreadDpu::GetStopReason(lldb_private::ThreadStopInfo&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (ThreadDpu.cpp:46)
==17528==    by 0x1B1E6F: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(unsigned long) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1B3D10: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::SendStopReasonForState(lldb::StateType) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1B3E3C: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::HandleInferiorState_Stopped(lldb_private::NativeProcessProtocol*) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1B3F59: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::ProcessStateChanged(lldb_private::NativeProcessProtocol*, lldb::StateType) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x15E373: lldb_private::NativeProcessProtocol::SynchronouslyNotifyProcessStateChanged(lldb::StateType) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x15E8F9: lldb_private::NativeProcessProtocol::SetState(lldb::StateType, bool) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x17DA15: lldb_private::process_dpu::ProcessDpu::InterfaceTimerCallback() (ProcessDpu.cpp:366)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1598A3: lldb_private::MainLoop::RunImpl::ProcessEvents() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x159CCF: lldb_private::MainLoop::Run() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==
==17528== Conditional jump or move depends on uninitialised value(s)
==17528==    at 0x182126: lldb_private::dpu::Dpu::GetThreadState(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, lldb::StopReason&, bool) (Dpu.cpp:785)
==17528==    by 0x18024D: lldb_private::process_dpu::ThreadDpu::GetStopReason(lldb_private::ThreadStopInfo&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (ThreadDpu.cpp:46)
==17528==    by 0x1B0599: GetJSONThreadsInfo(lldb_private::NativeProcessProtocol&, bool) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1B85C4: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::Handle_jThreadsInfo(StringExtractorGDBRemote&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A6E56: std::_Function_handler<lldb_private::process_gdb_remote::GDBRemoteCommunication::PacketResult (StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&), void lldb_private::process_gdb_remote::GDBRemoteCommunicationServerCommon::RegisterMemberFunctionHandler<lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS>(StringExtractorGDBRemote::ServerPacketType, lldb_private::process_
gdb_remote::GDBRemoteCommunication::PacketResult (lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::*)(StringExtractorGDBRemote&))::{lambda(StringExtractorGDBRemote, lldb_private::Status&, bool&, bool&)#1}>::_M_invoke(std::_Any_data const&, StringExtractorGDBRemote&, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x19839D: lldb_private::process_gdb_remote::GDBRemoteCommunicationServer::GetPacketAndSendResponse(lldb_private::Timeout<std::ratio<1l, 1000000l> >, lldb_private::Status&, bool&, bool&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1A8A74: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::DataAvailableCallback() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1597DE: lldb_private::MainLoop::ProcessReadObject(int) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1598A3: lldb_private::MainLoop::RunImpl::ProcessEvents() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x159CCF: lldb_private::MainLoop::Run() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x14C220: main_gdbserver(int, char**) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1473B2: main (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
```
The Dpu specifics d'tor wasn't or not well implemented.

This commit fix those `valgrind` report:

```
==17528== 288,802 (96 direct, 288,706 indirect) bytes in 1 blocks are definitely lost in loss record 187 of 187
==17528==    at 0x4835DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
==17528==    by 0x17F451: lldb_private::process_dpu::ProcessDpu::Factory::Launch(lldb_private::ProcessLaunchInfo&, lldb_private::NativeProcessProtocol::NativeDelegate&, lldb_private::MainLoop&) const (ProcessDpu.cpp:103)
==17528==    by 0x1AA7B9: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::LaunchProcess() (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x149271: handle_launch(lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS&, llvm::ArrayRef<llvm::StringRef>) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x14C19D: main_gdbserver(int, char**) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==17528==    by 0x1473B2: main (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
```
or
```
==32349== 280,107 (96 direct, 280,011 indirect) bytes in 1 blocks are definitely lost in loss record 149 of 149
==32349==    at 0x4835DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
==32349==    by 0x17F72B: lldb_private::process_dpu::ProcessDpu::Factory::Attach(unsigned long, lldb_private::NativeProcessProtocol::NativeDelegate&, lldb_private::MainLoop&) const (ProcessDpu.cpp:202)
==32349==    by 0x1AA199: lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS::AttachToProcess(unsigned long) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==32349==    by 0x148FA9: handle_attach_to_pid(lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS&, unsigned long) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==32349==    by 0x14906A: handle_attach(lldb_private::process_gdb_remote::GDBRemoteCommunicationServerLLGS&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==32349==    by 0x14C65B: main_gdbserver(int, char**) (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
==32349==    by 0x1473B2: main (in /scratch/wwolff/dpu_tools_rework_testsuite/bin/lldb-server-dpu)
```
@wwolff42 wwolff42 force-pushed the dev/wwolff/sanitize_20240305 branch from 3607018 to 8fa4b24 Compare March 8, 2024 10:03
@wwolff42 wwolff42 merged commit a00fdeb into upmem_release_120 Mar 8, 2024
wwolff42 added a commit that referenced this pull request Mar 8, 2024
wwolff42 added a commit that referenced this pull request Mar 8, 2024
@wwolff42 wwolff42 deleted the dev/wwolff/sanitize_20240305 branch March 8, 2024 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants