Skip to content

[lldb-dap] Restore the override FD used by the output redirect on stop. #129964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2025

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Mar 6, 2025

While running lldb-dap over stdin/stdout the stdout and stderr FD's are replaced with a pipe that is reading the output to forward to the dap client. During shutdown we were not properly restoring those FDs, which means if any component attempted to write to stderr it would trigger a SIGPIPE due to the pipe being closed during the shutdown process. This can happen if we have an error reported from the DAP::Loop call that would then log to stderr, such as an error parsing a malformed DAP message or if lldb-dap crashed and it was trying to write the stack trace to stderr.

There is one place we were not handling an llvm::Error if there was no logging setup that could trigger this condition.

To address this, I updated the OutputRedirector to restore the FD to the prior state when Stop is called.

While running lldb-dap over stdin/stdout the `stdout` and `stderr` FD's are replaced with a pipe that is reading the output to forward to the dap client. During shutdown we were not properly restoring those FDs, which means if any component attempted to write to stderr it would trigger a SIGPIPE due to the pipe being closed during the shutdown process. This can happen if we have an error reported from the `DAP::Loop` call that would then log to stderr, such as an error parsing a malformed DAP message or if lldb-dap crashed and it was trying to write the stack trace to stderr.

There is one place we were not handling an `llvm::Error` if there was no logging setup that could trigger this condition.

To address this, I updated the OutputRedirector to restore the FD to the prior state when `Stop` is called.
@ashgti ashgti marked this pull request as ready for review March 6, 2025 01:15
@ashgti ashgti requested a review from JDevlieghere as a code owner March 6, 2025 01:15
@llvmbot
Copy link
Member

llvmbot commented Mar 6, 2025

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

While running lldb-dap over stdin/stdout the stdout and stderr FD's are replaced with a pipe that is reading the output to forward to the dap client. During shutdown we were not properly restoring those FDs, which means if any component attempted to write to stderr it would trigger a SIGPIPE due to the pipe being closed during the shutdown process. This can happen if we have an error reported from the DAP::Loop call that would then log to stderr, such as an error parsing a malformed DAP message or if lldb-dap crashed and it was trying to write the stack trace to stderr.

There is one place we were not handling an llvm::Error if there was no logging setup that could trigger this condition.

To address this, I updated the OutputRedirector to restore the FD to the prior state when Stop is called.


Full diff: https://github.com/llvm/llvm-project/pull/129964.diff

4 Files Affected:

  • (modified) lldb/test/API/tools/lldb-dap/io/TestDAP_io.py (+13-12)
  • (modified) lldb/tools/lldb-dap/DAP.cpp (+7-33)
  • (modified) lldb/tools/lldb-dap/OutputRedirector.cpp (+29-2)
  • (modified) lldb/tools/lldb-dap/OutputRedirector.h (+4-1)
diff --git a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py
index a39bd17ceb3b3..04414cd7a3cdf 100644
--- a/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py
+++ b/lldb/test/API/tools/lldb-dap/io/TestDAP_io.py
@@ -18,18 +18,19 @@ def cleanup():
             # If the process is still alive, terminate it.
             if process.poll() is None:
                 process.terminate()
-                stdout_data = process.stdout.read()
-                stderr_data = process.stderr.read()
-                print("========= STDOUT =========")
-                print(stdout_data)
-                print("========= END =========")
-                print("========= STDERR =========")
-                print(stderr_data)
-                print("========= END =========")
-                print("========= DEBUG ADAPTER PROTOCOL LOGS =========")
-                with open(log_file_path, "r") as file:
-                    print(file.read())
-                print("========= END =========")
+                process.wait()
+            stdout_data = process.stdout.read()
+            stderr_data = process.stderr.read()
+            print("========= STDOUT =========")
+            print(stdout_data)
+            print("========= END =========")
+            print("========= STDERR =========")
+            print(stderr_data)
+            print("========= END =========")
+            print("========= DEBUG ADAPTER PROTOCOL LOGS =========")
+            with open(log_file_path, "r") as file:
+                print(file.read())
+            print("========= END =========")
 
         # Execute the cleanup function during test case tear down.
         self.addTearDownHook(cleanup)
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index b21b83a79aec7..1f7b25e7c5bcc 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -195,34 +195,16 @@ ExceptionBreakpoint *DAP::GetExceptionBreakpoint(const lldb::break_id_t bp_id) {
 llvm::Error DAP::ConfigureIO(std::FILE *overrideOut, std::FILE *overrideErr) {
   in = lldb::SBFile(std::fopen(DEV_NULL, "r"), /*transfer_ownership=*/true);
 
-  if (auto Error = out.RedirectTo([this](llvm::StringRef output) {
+  if (auto Error = out.RedirectTo(overrideOut, [this](llvm::StringRef output) {
         SendOutput(OutputType::Stdout, output);
       }))
     return Error;
 
-  if (overrideOut) {
-    auto fd = out.GetWriteFileDescriptor();
-    if (auto Error = fd.takeError())
-      return Error;
-
-    if (dup2(*fd, fileno(overrideOut)) == -1)
-      return llvm::errorCodeToError(llvm::errnoAsErrorCode());
-  }
-
-  if (auto Error = err.RedirectTo([this](llvm::StringRef output) {
+  if (auto Error = err.RedirectTo(overrideErr, [this](llvm::StringRef output) {
         SendOutput(OutputType::Stderr, output);
       }))
     return Error;
 
-  if (overrideErr) {
-    auto fd = err.GetWriteFileDescriptor();
-    if (auto Error = fd.takeError())
-      return Error;
-
-    if (dup2(*fd, fileno(overrideErr)) == -1)
-      return llvm::errorCodeToError(llvm::errnoAsErrorCode());
-  }
-
   return llvm::Error::success();
 }
 
@@ -729,15 +711,11 @@ PacketStatus DAP::GetNextObject(llvm::json::Object &object) {
 
   llvm::StringRef json_sref(json);
   llvm::Expected<llvm::json::Value> json_value = llvm::json::parse(json_sref);
-  if (!json_value) {
-    auto error = json_value.takeError();
-    if (log) {
-      std::string error_str;
-      llvm::raw_string_ostream strm(error_str);
-      strm << error;
+  if (auto error = json_value.takeError()) {
+    std::string error_str = llvm::toString(std::move(error));
+    if (log)
       *log << "error: failed to parse JSON: " << error_str << std::endl
            << json << std::endl;
-    }
     return PacketStatus::JSONMalformed;
   }
 
@@ -848,10 +826,6 @@ lldb::SBError DAP::Disconnect(bool terminateDebuggee) {
 
   SendTerminatedEvent();
 
-  // Stop forwarding the debugger output and error handles.
-  out.Stop();
-  err.Stop();
-
   disconnecting = true;
 
   return error;
@@ -859,8 +833,8 @@ lldb::SBError DAP::Disconnect(bool terminateDebuggee) {
 
 llvm::Error DAP::Loop() {
   auto cleanup = llvm::make_scope_exit([this]() {
-    if (output.descriptor)
-      output.descriptor->Close();
+    out.Stop();
+    err.Stop();
     StopEventHandlers();
   });
   while (!disconnecting) {
diff --git a/lldb/tools/lldb-dap/OutputRedirector.cpp b/lldb/tools/lldb-dap/OutputRedirector.cpp
index 79321aebe9aac..5da3839973706 100644
--- a/lldb/tools/lldb-dap/OutputRedirector.cpp
+++ b/lldb/tools/lldb-dap/OutputRedirector.cpp
@@ -27,7 +27,9 @@ namespace lldb_dap {
 
 int OutputRedirector::kInvalidDescriptor = -1;
 
-OutputRedirector::OutputRedirector() : m_fd(kInvalidDescriptor) {}
+OutputRedirector::OutputRedirector()
+    : m_fd(kInvalidDescriptor), m_original_fd(kInvalidDescriptor),
+      m_restore_fd(kInvalidDescriptor) {}
 
 Expected<int> OutputRedirector::GetWriteFileDescriptor() {
   if (m_fd == kInvalidDescriptor)
@@ -36,7 +38,8 @@ Expected<int> OutputRedirector::GetWriteFileDescriptor() {
   return m_fd;
 }
 
-Error OutputRedirector::RedirectTo(std::function<void(StringRef)> callback) {
+Error OutputRedirector::RedirectTo(std::FILE *override,
+                                   std::function<void(StringRef)> callback) {
   assert(m_fd == kInvalidDescriptor && "Output readirector already started.");
   int new_fd[2];
 
@@ -52,6 +55,19 @@ Error OutputRedirector::RedirectTo(std::function<void(StringRef)> callback) {
 
   int read_fd = new_fd[0];
   m_fd = new_fd[1];
+
+  if (override) {
+    int override_fd = fileno(override);
+
+    // Backup the FD to restore once redirection is complete.
+    m_original_fd = override_fd;
+    m_restore_fd = dup(override_fd);
+
+    // Override the existing fd the new write end of the pipe.
+    if (::dup2(m_fd, override_fd) == -1)
+      return llvm::errorCodeToError(llvm::errnoAsErrorCode());
+  }
+
   m_forwarder = std::thread([this, callback, read_fd]() {
     char buffer[OutputBufferSize];
     while (!m_stopped) {
@@ -92,6 +108,17 @@ void OutputRedirector::Stop() {
     (void)::write(fd, kCloseSentinel.data(), kCloseSentinel.size());
     ::close(fd);
     m_forwarder.join();
+
+    // Restore the fd back to its original state since we stopped the
+    // redirection.
+    if (m_restore_fd != kInvalidDescriptor &&
+        m_original_fd != kInvalidDescriptor) {
+      int restore_fd = m_restore_fd;
+      m_restore_fd = kInvalidDescriptor;
+      int original_fd = m_original_fd;
+      m_original_fd = kInvalidDescriptor;
+      ::dup2(restore_fd, original_fd);
+    }
   }
 }
 
diff --git a/lldb/tools/lldb-dap/OutputRedirector.h b/lldb/tools/lldb-dap/OutputRedirector.h
index a47ea96f71f14..45571c0d5f344 100644
--- a/lldb/tools/lldb-dap/OutputRedirector.h
+++ b/lldb/tools/lldb-dap/OutputRedirector.h
@@ -27,7 +27,8 @@ class OutputRedirector {
   /// \return
   ///     \a Error::success if the redirection was set up correctly, or an error
   ///     otherwise.
-  llvm::Error RedirectTo(std::function<void(llvm::StringRef)> callback);
+  llvm::Error RedirectTo(std::FILE *overrideFile,
+                         std::function<void(llvm::StringRef)> callback);
 
   llvm::Expected<int> GetWriteFileDescriptor();
   void Stop();
@@ -41,6 +42,8 @@ class OutputRedirector {
 private:
   std::atomic<bool> m_stopped = false;
   int m_fd;
+  int m_original_fd;
+  int m_restore_fd;
   std::thread m_forwarder;
 };
 

@ashgti
Copy link
Contributor Author

ashgti commented Mar 6, 2025

Checking this with:

$ echo 'Content-Length: 51\r\n\r\n{"command":"disconnect","seq": 1,"type": "request"' > /tmp/partial_message
$ lldb lldb-dap
(lldb) process handle -s true SIGPIPE
(lldb) process launch -i /tmp/partial_message

Without the LLDBDAP_LOG env set is how I found the crash and the SIGPIPE write error. It was from logging here

llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(),

@JDevlieghere
Copy link
Member

Thanks, I've confirmed this fixes the issue for me. Ironically, it's my MemoryMonitor patch that triggered it, I guess it caused something to get written to stdout/stderr.

@ashgti ashgti merged commit 27c788d into llvm:main Mar 6, 2025
7 of 9 checks passed
@ashgti ashgti deleted the lldb-dap-shutdown-fd-cleanup branch March 6, 2025 21:57
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 6, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building lldb at step 4 "build".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/162/builds/17524

Here is the relevant piece of the build log for the reference
Step 4 (build) failure: build (failure)
...
2.780 [123/39/18] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/DataBreakpointInfoRequestHandler.cpp.o
2.809 [123/38/19] Building CXX object tools/llvm-config/CMakeFiles/llvm-config.dir/llvm-config.cpp.o
2.840 [122/38/20] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/DisassembleRequestHandler.cpp.o
2.878 [122/37/21] Linking CXX executable bin/llvm-config
2.885 [122/36/22] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/InitializeRequestHandler.cpp.o
2.911 [122/35/23] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/BreakpointLocationsHandler.cpp.o
2.965 [122/34/24] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetBreakpointsRequestHandler.cpp.o
3.044 [122/33/25] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/FunctionBreakpoint.cpp.o
3.066 [122/32/26] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/StepOutRequestHandler.cpp.o
3.076 [122/31/27] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o
FAILED: tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/tools/lldb-dap -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-dap -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/include -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include -I/usr/include/python3.11 -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/../clang/include -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -MF tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o.d -o tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -c /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:59:7: error: use of undeclared identifier 'override'
  if (override) {
      ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:60:30: error: use of undeclared identifier 'override'
    int override_fd = fileno(override);
                             ^
2 errors generated.
3.097 [122/30/28] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/EvaluateRequestHandler.cpp.o
3.099 [122/29/29] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/StepInRequestHandler.cpp.o
3.142 [122/28/30] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ThreadsRequestHandler.cpp.o
3.159 [122/27/31] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetExceptionBreakpointsRequestHandler.cpp.o
3.160 [122/26/32] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Watchpoint.cpp.o
3.168 [122/25/33] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/TestGetTargetBreakpointsRequestHandler.cpp.o
3.177 [122/24/34] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/LLDBUtils.cpp.o
3.199 [122/23/35] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetVariableRequestHandler.cpp.o
3.201 [122/22/36] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ContinueRequestHandler.cpp.o
3.238 [122/21/37] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/CompileUnitsRequestHandler.cpp.o
3.245 [122/20/38] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/RequestHandler.cpp.o
3.263 [122/19/39] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SourceRequestHandler.cpp.o
3.264 [122/18/40] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ScopesRequestHandler.cpp.o
3.269 [122/17/41] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/LaunchRequestHandler.cpp.o
3.282 [122/16/42] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetDataBreakpointsRequestHandler.cpp.o
3.308 [122/15/43] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/EventHelper.cpp.o
3.325 [122/14/44] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetFunctionBreakpointsRequestHandler.cpp.o
3.328 [122/13/45] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/SourceBreakpoint.cpp.o
3.341 [122/12/46] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/VariablesRequestHandler.cpp.o
3.367 [122/11/47] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/StepInTargetsRequestHandler.cpp.o
3.380 [122/10/48] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetInstructionBreakpointsRequestHandler.cpp.o
3.417 [122/9/49] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/CompletionsHandler.cpp.o
3.464 [122/8/50] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/StackTraceRequestHandler.cpp.o
3.515 [122/7/51] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
3.655 [122/6/52] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ReadMemoryRequestHandler.cpp.o
4.207 [122/5/53] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/DAP.cpp.o
4.717 [122/4/54] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/JSONUtils.cpp.o
5.302 [122/3/55] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/lldb-dap.cpp.o
10.948 [122/2/56] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
12.164 [122/1/57] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 6, 2025

LLVM Buildbot has detected a new failure on builder cross-project-tests-sie-ubuntu running on doug-worker-1a while building lldb at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/181/builds/14956

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
1.017 [157/8/8] Building CXX object tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Version.cpp.o
2.364 [156/8/9] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/FunctionBreakpoint.cpp.o
3.163 [155/8/10] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/EventHelper.cpp.o
3.369 [154/8/11] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/ExceptionBreakpoint.cpp.o
4.180 [153/8/12] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
4.287 [152/8/13] Linking CXX static library lib/libLLVMObject.a
4.677 [151/8/14] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/InstructionBreakpoint.cpp.o
5.787 [150/8/15] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/DAP.cpp.o
5.939 [149/8/16] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/LLDBUtils.cpp.o
6.581 [148/8/17] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o
FAILED: tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/tools/lldb-dap -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include -I/usr/include/python3.8 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/../clang/include -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -MF tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o.d -o tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -c /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp: In member function ‘llvm::Error lldb_dap::OutputRedirector::RedirectTo(FILE*, std::function<void(llvm::StringRef)>)’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:59:7: error: ‘override’ was not declared in this scope
   59 |   if (override) {
      |       ^~~~~~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp: In member function ‘void lldb_dap::OutputRedirector::Stop()’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:108:18: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
  108 |     (void)::write(fd, kCloseSentinel.data(), kCloseSentinel.size());
      |           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7.321 [148/7/18] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/lldb-dap.cpp.o
7.533 [148/6/19] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/SourceBreakpoint.cpp.o
8.283 [148/5/20] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/JSONUtils.cpp.o
8.395 [148/4/21] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Watchpoint.cpp.o
8.708 [148/3/22] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/AttachRequestHandler.cpp.o
15.729 [148/2/23] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
16.444 [148/1/24] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 6, 2025

LLVM Buildbot has detected a new failure on builder lldb-arm-ubuntu running on linaro-lldb-arm-ubuntu while building lldb at step 4 "build".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/18/builds/12507

Here is the relevant piece of the build log for the reference
Step 4 (build) failure: build (failure)
...
61.872 [1/24/6511] Linking CXX executable bin/lldb
62.225 [1/23/6512] Linking CXX executable bin/c-index-test
62.465 [1/22/6513] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/DataBreakpointInfoRequestHandler.cpp.o
62.529 [1/21/6514] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/JSONUtils.cpp.o
62.853 [1/20/6515] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/NextRequestHandler.cpp.o
63.134 [1/19/6516] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/DAP.cpp.o
63.533 [1/18/6517] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/DisconnectRequestHandler.cpp.o
63.648 [1/17/6518] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/ExceptionBreakpoint.cpp.o
63.821 [1/16/6519] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/lldb-dap.cpp.o
63.848 [1/15/6520] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o
FAILED: tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLVM_BUILD_STATIC -D_DEBUG -D_FILE_OFFSET_BITS=64 -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/tools/lldb-dap -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/tools/lldb-dap -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/include -I/usr/include/python3.10 -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/../clang/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/../clang/include -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -MF tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o.d -o tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -c /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp
../llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:59:7: error: use of undeclared identifier 'override'
   59 |   if (override) {
      |       ^
../llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:60:30: error: use of undeclared identifier 'override'
   60 |     int override_fd = fileno(override);
      |                              ^
2 errors generated.
63.883 [1/14/6521] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/PauseRequestHandler.cpp.o
63.902 [1/13/6522] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ConfigurationDoneRequestHandler.cpp.o
64.262 [1/12/6523] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/CompileUnitsRequestHandler.cpp.o
64.278 [1/11/6524] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ModulesRequestHandler.cpp.o
64.285 [1/10/6525] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/StackTraceRequestHandler.cpp.o
64.436 [1/9/6526] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/CompletionsHandler.cpp.o
64.635 [1/8/6527] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetBreakpointsRequestHandler.cpp.o
64.754 [1/7/6528] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ExceptionInfoRequestHandler.cpp.o
64.821 [1/6/6529] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/ReadMemoryRequestHandler.cpp.o
64.930 [1/5/6530] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetDataBreakpointsRequestHandler.cpp.o
64.958 [1/4/6531] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/RestartRequestHandler.cpp.o
65.012 [1/3/6532] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/VariablesRequestHandler.cpp.o
65.235 [1/2/6533] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/SetFunctionBreakpointsRequestHandler.cpp.o
65.328 [1/1/6534] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/Handler/DisassembleRequestHandler.cpp.o
ninja: build stopped: subcommand failed.

@ashgti
Copy link
Contributor Author

ashgti commented Mar 6, 2025

#130186 should fix the failure.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 7, 2025

LLVM Buildbot has detected a new failure on builder llvm-x86_64-debian-dylib running on gribozavr4 while building lldb at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/21306

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
97.117 [324/96/6785] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/PdbAstBuilder.cpp.o
97.120 [323/96/6786] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/PdbFPOProgramToDWARFExpression.cpp.o
97.127 [322/96/6787] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/PdbIndex.cpp.o
97.133 [321/96/6788] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/PdbSymUid.cpp.o
97.134 [320/96/6789] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/PdbUtil.cpp.o
97.135 [319/96/6790] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/SymbolFileNativePDB.cpp.o
97.137 [318/96/6791] Building CXX object tools/lldb/source/Plugins/SymbolFile/NativePDB/CMakeFiles/lldbPluginSymbolFileNativePDB.dir/UdtRecordCompleter.cpp.o
97.142 [317/96/6792] Building CXX object tools/lldb/source/Plugins/SymbolFile/PDB/CMakeFiles/lldbPluginSymbolFilePDB.dir/PDBLocationToDWARFExpression.cpp.o
97.150 [316/96/6793] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/LLDBUtils.cpp.o
97.152 [315/96/6794] Building CXX object tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o
FAILED: tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/tools/lldb-dap -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/tools/lldb-dap -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/../clang/include -isystem /usr/include/libxml2 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -MF tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o.d -o tools/lldb/tools/lldb-dap/CMakeFiles/lldb-dap.dir/OutputRedirector.cpp.o -c /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:59:7: error: use of undeclared identifier 'override'
  if (override) {
      ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/tools/lldb-dap/OutputRedirector.cpp:60:30: error: use of undeclared identifier 'override'
    int override_fd = fileno(override);
                             ^
2 errors generated.
97.153 [315/95/6795] Building CXX object tools/lldb/source/Plugins/SymbolFile/PDB/CMakeFiles/lldbPluginSymbolFilePDB.dir/PDBASTParser.cpp.o
97.155 [315/94/6796] Building CXX object tools/lldb/source/Plugins/SymbolFile/PDB/CMakeFiles/lldbPluginSymbolFilePDB.dir/SymbolFilePDB.cpp.o
97.155 [315/93/6797] Building CXX object tools/lldb/source/Plugins/SymbolFile/Symtab/CMakeFiles/lldbPluginSymbolFileSymtab.dir/SymbolFileSymtab.cpp.o
97.156 [315/92/6798] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AppleGetItemInfoHandler.cpp.o
97.157 [315/91/6799] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AppleGetPendingItemsHandler.cpp.o
97.158 [315/90/6800] Linking CXX static library lib/libclangDaemonTweaks.a
97.158 [315/89/6801] Linking CXX static library lib/libclangdMain.a
97.158 [315/88/6802] Linking CXX executable bin/dexp
97.159 [315/87/6803] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AppleGetQueuesHandler.cpp.o
97.160 [315/86/6804] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AppleGetThreadItemInfoHandler.cpp.o
97.161 [315/85/6805] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/SystemRuntimeMacOSX.cpp.o
97.162 [315/84/6806] Building CXX object tools/lldb/source/Plugins/SystemRuntime/MacOSX/CMakeFiles/lldbPluginSystemRuntimeMacOSX.dir/AbortWithPayloadFrameRecognizer.cpp.o
97.162 [315/83/6807] Building CXX object tools/lldb/source/Plugins/SymbolLocator/Debuginfod/CMakeFiles/lldbPluginSymbolLocatorDebuginfod.dir/SymbolLocatorDebuginfod.cpp.o
97.163 [315/82/6808] Building CXX object tools/lldb/source/Plugins/SymbolLocator/Default/CMakeFiles/lldbPluginSymbolLocatorDefault.dir/SymbolLocatorDefault.cpp.o
97.164 [315/81/6809] Building CXX object tools/lldb/source/Plugins/SymbolVendor/ELF/CMakeFiles/lldbPluginSymbolVendorELF.dir/SymbolVendorELF.cpp.o
97.165 [315/80/6810] Building CXX object tools/lldb/source/Plugins/SymbolVendor/PECOFF/CMakeFiles/lldbPluginSymbolVendorPECOFF.dir/SymbolVendorPECOFF.cpp.o
97.165 [315/79/6811] Building CXX object tools/lldb/source/Plugins/SymbolVendor/wasm/CMakeFiles/lldbPluginSymbolVendorWasm.dir/SymbolVendorWasm.cpp.o
97.167 [315/78/6812] Building CXX object tools/lldb/source/Plugins/Trace/common/CMakeFiles/lldbPluginTraceCommon.dir/ThreadPostMortemTrace.cpp.o
97.168 [315/77/6813] Building CXX object tools/lldb/source/Plugins/TraceExporter/common/CMakeFiles/lldbPluginTraceExporterCommon.dir/TraceHTR.cpp.o
97.169 [315/76/6814] Building CXX object tools/lldb/source/Plugins/TraceExporter/ctf/CMakeFiles/lldbPluginTraceExporterCTF.dir/CommandObjectThreadTraceExportCTF.cpp.o
97.169 [315/75/6815] Building CXX object tools/lldb/source/Plugins/TraceExporter/ctf/CMakeFiles/lldbPluginTraceExporterCTF.dir/TraceExporterCTF.cpp.o
97.171 [315/74/6816] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
97.171 [315/73/6817] Building CXX object tools/lldb/source/Plugins/UnwindAssembly/InstEmulation/CMakeFiles/lldbPluginUnwindAssemblyInstEmulation.dir/UnwindAssemblyInstEmulation.cpp.o
97.172 [315/72/6818] Building CXX object tools/lldb/source/Plugins/UnwindAssembly/x86/CMakeFiles/lldbPluginUnwindAssemblyX86.dir/UnwindAssembly-x86.cpp.o
97.172 [315/71/6819] Building CXX object tools/lldb/source/Plugins/UnwindAssembly/x86/CMakeFiles/lldbPluginUnwindAssemblyX86.dir/x86AssemblyInspectionEngine.cpp.o
97.172 [315/70/6820] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/ArmUnwindInfo.cpp.o
97.173 [315/69/6821] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/Block.cpp.o
97.173 [315/68/6822] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompactUnwindInfo.cpp.o
97.174 [315/67/6823] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompileUnit.cpp.o
97.175 [315/66/6824] Building CXX object tools/lldb/source/Symbol/CMakeFiles/lldbSymbol.dir/CompilerDecl.cpp.o

jph-13 pushed a commit to jph-13/llvm-project that referenced this pull request Mar 21, 2025
…p. (llvm#129964)

While running lldb-dap over stdin/stdout the `stdout` and `stderr` FD's
are replaced with a pipe that is reading the output to forward to the
dap client. During shutdown we were not properly restoring those FDs,
which means if any component attempted to write to stderr it would
trigger a SIGPIPE due to the pipe being closed during the shutdown
process. This can happen if we have an error reported from the
`DAP::Loop` call that would then log to stderr, such as an error parsing
a malformed DAP message or if lldb-dap crashed and it was trying to
write the stack trace to stderr.

There is one place we were not handling an `llvm::Error` if there was no
logging setup that could trigger this condition.

To address this, I updated the OutputRedirector to restore the FD to the
prior state when `Stop` is called.

---------

Co-authored-by: Jonas Devlieghere <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants