Author: Jason Molenda Date: 2023-08-18T16:25:50-07:00 New Revision: 18b211cb15213f984b2014413b74958243a4805f
URL: https://github.com/llvm/llvm-project/commit/18b211cb15213f984b2014413b74958243a4805f DIFF: https://github.com/llvm/llvm-project/commit/18b211cb15213f984b2014413b74958243a4805f.diff LOG: Disable stdin/stdout for environment_check inferior process To work around an address sanitizer issue on macOS where environment_check prints a spurious stderr msg when executing, environment_check(41292,0x113e7a600) malloc: nano zone abandoned due to inability to preallocate reserved vm space. And TestClient::Continue() which intends to continue to exit instead sees the stderr output streamed, and doesn't handle that unexpected output. Easiest to disable stdin/stdout for this one test case to avoid this corner case issue with this TestClient.cpp way of expecting a stop reply packet after continuing. Differential Revision: https://reviews.llvm.org/D158237 Added: Modified: lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp lldb/unittests/tools/lldb-server/tests/TestClient.cpp lldb/unittests/tools/lldb-server/tests/TestClient.h Removed: ################################################################################ diff --git a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp index 92efeffde7f19e..1f53b6d9d9944e 100644 --- a/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp +++ b/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp @@ -41,9 +41,10 @@ TEST_F(TestBase, DS_TEST(DebugserverEnv)) { // Test that --env takes precedence over inherited environment variables. putenv(const_cast<char *>("LLDB_TEST_MAGIC_VARIABLE=foobar")); - auto ClientOr = TestClient::launchCustom(getLogFileName(), - { "--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE" }, - {getInferiorPath("environment_check")}); + auto ClientOr = TestClient::launchCustom( + getLogFileName(), /* disable_stdio */ true, + {"--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE"}, + {getInferiorPath("environment_check")}); ASSERT_THAT_EXPECTED(ClientOr, Succeeded()); auto &Client = **ClientOr; diff --git a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp index 232f725baf58a7..2d7ce36bacfaa3 100644 --- a/lldb/unittests/tools/lldb-server/tests/TestClient.cpp +++ b/lldb/unittests/tools/lldb-server/tests/TestClient.cpp @@ -59,10 +59,13 @@ Expected<std::unique_ptr<TestClient>> TestClient::launch(StringRef Log) { } Expected<std::unique_ptr<TestClient>> TestClient::launch(StringRef Log, ArrayRef<StringRef> InferiorArgs) { - return launchCustom(Log, {}, InferiorArgs); + return launchCustom(Log, false, {}, InferiorArgs); } -Expected<std::unique_ptr<TestClient>> TestClient::launchCustom(StringRef Log, ArrayRef<StringRef> ServerArgs, ArrayRef<StringRef> InferiorArgs) { +Expected<std::unique_ptr<TestClient>> +TestClient::launchCustom(StringRef Log, bool disable_stdio, + ArrayRef<StringRef> ServerArgs, + ArrayRef<StringRef> InferiorArgs) { const ArchSpec &arch_spec = HostInfo::GetArchitecture(); Args args; args.AppendArgument(LLDB_SERVER); @@ -111,6 +114,8 @@ Expected<std::unique_ptr<TestClient>> TestClient::launchCustom(StringRef Log, Ar // Accept(). Info.SetMonitorProcessCallback(&ProcessLaunchInfo::NoOpMonitorCallback); + if (disable_stdio) + Info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO); status = Host::LaunchProcess(Info); if (status.Fail()) return status.ToError(); diff --git a/lldb/unittests/tools/lldb-server/tests/TestClient.h b/lldb/unittests/tools/lldb-server/tests/TestClient.h index 9a1831d4dbc174..deb6802d0da707 100644 --- a/lldb/unittests/tools/lldb-server/tests/TestClient.h +++ b/lldb/unittests/tools/lldb-server/tests/TestClient.h @@ -48,8 +48,9 @@ class TestClient /// using this for generic tests, as the two stubs have diff erent /// command-line interfaces. static llvm::Expected<std::unique_ptr<TestClient>> - launchCustom(llvm::StringRef Log, llvm::ArrayRef<llvm::StringRef> ServerArgs, llvm::ArrayRef<llvm::StringRef> InferiorArgs); - + launchCustom(llvm::StringRef Log, bool disable_stdio, + llvm::ArrayRef<llvm::StringRef> ServerArgs, + llvm::ArrayRef<llvm::StringRef> InferiorArgs); ~TestClient() override; llvm::Error SetInferior(llvm::ArrayRef<std::string> inferior_args); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits