Skip to content

Commit 18b211c

Browse files
committed
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
1 parent 03b43d3 commit 18b211c

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ TEST_F(TestBase, DS_TEST(DebugserverEnv)) {
4141
// Test that --env takes precedence over inherited environment variables.
4242
putenv(const_cast<char *>("LLDB_TEST_MAGIC_VARIABLE=foobar"));
4343

44-
auto ClientOr = TestClient::launchCustom(getLogFileName(),
45-
{ "--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE" },
46-
{getInferiorPath("environment_check")});
44+
auto ClientOr = TestClient::launchCustom(
45+
getLogFileName(), /* disable_stdio */ true,
46+
{"--env", "LLDB_TEST_MAGIC_VARIABLE=LLDB_TEST_MAGIC_VALUE"},
47+
{getInferiorPath("environment_check")});
4748
ASSERT_THAT_EXPECTED(ClientOr, Succeeded());
4849
auto &Client = **ClientOr;
4950

lldb/unittests/tools/lldb-server/tests/TestClient.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@ Expected<std::unique_ptr<TestClient>> TestClient::launch(StringRef Log) {
5959
}
6060

6161
Expected<std::unique_ptr<TestClient>> TestClient::launch(StringRef Log, ArrayRef<StringRef> InferiorArgs) {
62-
return launchCustom(Log, {}, InferiorArgs);
62+
return launchCustom(Log, false, {}, InferiorArgs);
6363
}
6464

65-
Expected<std::unique_ptr<TestClient>> TestClient::launchCustom(StringRef Log, ArrayRef<StringRef> ServerArgs, ArrayRef<StringRef> InferiorArgs) {
65+
Expected<std::unique_ptr<TestClient>>
66+
TestClient::launchCustom(StringRef Log, bool disable_stdio,
67+
ArrayRef<StringRef> ServerArgs,
68+
ArrayRef<StringRef> InferiorArgs) {
6669
const ArchSpec &arch_spec = HostInfo::GetArchitecture();
6770
Args args;
6871
args.AppendArgument(LLDB_SERVER);
@@ -111,6 +114,8 @@ Expected<std::unique_ptr<TestClient>> TestClient::launchCustom(StringRef Log, Ar
111114
// Accept().
112115
Info.SetMonitorProcessCallback(&ProcessLaunchInfo::NoOpMonitorCallback);
113116

117+
if (disable_stdio)
118+
Info.GetFlags().Set(lldb::eLaunchFlagDisableSTDIO);
114119
status = Host::LaunchProcess(Info);
115120
if (status.Fail())
116121
return status.ToError();

lldb/unittests/tools/lldb-server/tests/TestClient.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class TestClient
4848
/// using this for generic tests, as the two stubs have different
4949
/// command-line interfaces.
5050
static llvm::Expected<std::unique_ptr<TestClient>>
51-
launchCustom(llvm::StringRef Log, llvm::ArrayRef<llvm::StringRef> ServerArgs, llvm::ArrayRef<llvm::StringRef> InferiorArgs);
52-
51+
launchCustom(llvm::StringRef Log, bool disable_stdio,
52+
llvm::ArrayRef<llvm::StringRef> ServerArgs,
53+
llvm::ArrayRef<llvm::StringRef> InferiorArgs);
5354

5455
~TestClient() override;
5556
llvm::Error SetInferior(llvm::ArrayRef<std::string> inferior_args);

0 commit comments

Comments
 (0)