Skip to content

Commit 1903ad0

Browse files
committed
[lldb/windows] Make "anonymous" pipe names more unique
Using a "random" name for an "anonymous" pipe seems to be the state of the art on windows (according to stack overflow, new windows versions may have something better, but it involves calling kernel APIs directly and generally a lot of dark magic). The problem with the current method was that is does not produce unique names if one has two copies of the pipe code in the same process, which is what happened with llvm#120457 (because liblldb only exposes the public api, and we've started using the pipe code in lldb-dap as well). This patch works around the problem by adding the address of the counter variable to the pipe name. Replicating the multiple-copies setup in a test would be very difficult, which is why I'm not adding a test for this scenario.
1 parent 79231a8 commit 1903ad0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lldb/source/Host/windows/PipeWindows.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ Status PipeWindows::CreateNew(bool child_process_inherit) {
7171
// cannot get overlapped i/o on Windows without using a named pipe. So we
7272
// synthesize a unique name.
7373
uint32_t serial = g_pipe_serial.fetch_add(1);
74-
std::string pipe_name;
75-
llvm::raw_string_ostream pipe_name_stream(pipe_name);
76-
pipe_name_stream << "lldb.pipe." << ::GetCurrentProcessId() << "." << serial;
74+
std::string pipe_name = llvm::formatv(
75+
"lldb.pipe.{0}.{1}.{2}", GetCurrentProcessId(), &g_pipe_serial, serial);
7776

7877
return CreateNew(pipe_name.c_str(), child_process_inherit);
7978
}

0 commit comments

Comments
 (0)