llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) <details> <summary>Changes</summary> On Windows, file descriptor are only valid in the same DLL: they are really just handles mapped to an index in a table in the CRT. Calling a liblldb method with a file descriptor from lldb-dap will cause the program to crash. This patch fixes the issue by removing the use of the the `SBFile(FILE *file, bool transfer_ownership)` constructor in lldb-dap. --- Full diff: https://github.com/llvm/llvm-project/pull/195855.diff 1 Files Affected: - (modified) lldb/tools/lldb-dap/DAP.cpp (+7-1) ``````````diff diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index 7b58fca0f8163..21a01cb1515e6 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -31,9 +31,11 @@ #include "lldb/API/SBMutex.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/JSONTransport.h" #include "lldb/Host/MainLoop.h" #include "lldb/Host/MainLoopBase.h" +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -232,7 +234,11 @@ 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 file = FileSystem::Instance().Open(FileSpec(DEV_NULL), + File::eOpenOptionReadOnly)) + in = lldb::SBFile(lldb::FileSP(std::move(*file))); + else + llvm::consumeError(file.takeError()); if (auto Error = out.RedirectTo(overrideOut, [this](llvm::StringRef output) { SendOutput(OutputType::Console, output); `````````` </details> https://github.com/llvm/llvm-project/pull/195855 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
