https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/195855
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. >From 198ae496feed4678581ab51b13db9962960695c6 Mon Sep 17 00:00:00 2001 From: Charles Zablit <[email protected]> Date: Tue, 5 May 2026 11:55:35 +0100 Subject: [PATCH] [lldb-dap][windows] fix crash --- lldb/tools/lldb-dap/DAP.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
