[lldb] Fix PipeTest name collision in unit tests

We had two classes named `PipeTest`: one in `PipeTestUtilities.h` and
one in `PipeTest.cpp`. The latter was unintentionally using the wrong
class (from the header) which didn't initialize the HostInfo subsystem.

This resulted in a crash due to a nullptr dereference (`g_fields`) when
`PipePosix::CreateWithUniqueName` called `HostInfoBase::GetProcessTempDir`.
This commit is contained in:
Jonas Devlieghere
2025-07-01 15:56:22 -07:00
parent e9c9f8f374
commit e89458d398
4 changed files with 5 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ using lldb_private::NativeFile;
using lldb_private::Pipe; using lldb_private::Pipe;
void TransportBase::SetUp() { void TransportBase::SetUp() {
PipeTest::SetUp(); PipePairTest::SetUp();
to_dap = std::make_unique<Transport>( to_dap = std::make_unique<Transport>(
"to_dap", nullptr, "to_dap", nullptr,
std::make_shared<NativeFile>(input.GetReadFileDescriptor(), std::make_shared<NativeFile>(input.GetReadFileDescriptor(),

View File

@@ -18,7 +18,7 @@ namespace lldb_dap_tests {
/// A base class for tests that need transport configured for communicating DAP /// A base class for tests that need transport configured for communicating DAP
/// messages. /// messages.
class TransportBase : public PipeTest { class TransportBase : public PipePairTest {
protected: protected:
std::unique_ptr<lldb_dap::Transport> to_dap; std::unique_ptr<lldb_dap::Transport> to_dap;
std::unique_ptr<lldb_dap::Transport> from_dap; std::unique_ptr<lldb_dap::Transport> from_dap;

View File

@@ -14,12 +14,12 @@ using namespace llvm;
using namespace lldb_private; using namespace lldb_private;
namespace { namespace {
template <typename T> class JSONTransportTest : public PipeTest { template <typename T> class JSONTransportTest : public PipePairTest {
protected: protected:
std::unique_ptr<JSONTransport> transport; std::unique_ptr<JSONTransport> transport;
void SetUp() override { void SetUp() override {
PipeTest::SetUp(); PipePairTest::SetUp();
transport = std::make_unique<T>( transport = std::make_unique<T>(
std::make_shared<NativeFile>(input.GetReadFileDescriptor(), std::make_shared<NativeFile>(input.GetReadFileDescriptor(),
File::eOpenOptionReadOnly, File::eOpenOptionReadOnly,

View File

@@ -14,7 +14,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
/// A base class for tests that need a pair of pipes for communication. /// A base class for tests that need a pair of pipes for communication.
class PipeTest : public testing::Test { class PipePairTest : public testing::Test {
protected: protected:
lldb_private::Pipe input; lldb_private::Pipe input;
lldb_private::Pipe output; lldb_private::Pipe output;