Skip to content

Commit 846fa24

Browse files
committed
dpu: llvm: lldb: DpuContext: fix initialization ordering
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== ```
1 parent 12c0e15 commit 846fa24

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lldb/source/Plugins/Process/Dpu/DpuContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ DpuContext::DpuContext(dpu_t *dpu, struct dpu_context_t *context,
5050
}
5151
running_threads[0] = 0;
5252
last_resume_threads[0] = 0;
53+
54+
m_context->bkp_fault = false;
55+
m_context->dma_fault = false;
56+
m_context->mem_fault = false;
5357
}
5458

5559
DpuContext::~DpuContext() {
@@ -82,10 +86,6 @@ void DpuContext::UpdateRunningThreads() {
8286
bool DpuContext::StopThreads(uint32_t error_store_addr) {
8387
ResetScheduling();
8488

85-
m_context->bkp_fault = false;
86-
m_context->dma_fault = false;
87-
m_context->mem_fault = false;
88-
8989
int ret = DPU_OK;
9090
ret =
9191
dpu_initialize_fault_process_for_dpu(m_dpu, m_context, error_store_addr);

0 commit comments

Comments
 (0)