[llvm-branch-commits] [lldb] release/22.x: [lldb-dap] Fix crash in source request handler (#195847) (PR #196084)

2026-05-06 Thread Sergei Druzhkov via llvm-branch-commits

https://github.com/DrSergei approved this pull request.


https://github.com/llvm/llvm-project/pull/196084
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] release/22.x: [lldb-dap] Fix crash in source request handler (#195847) (PR #196084)

2026-05-06 Thread via llvm-branch-commits

llvmbot wrote:

@DrSergei @adrian-prantl What do you think about merging this PR to the release 
branch?

https://github.com/llvm/llvm-project/pull/196084
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] release/22.x: [lldb-dap] Fix crash in source request handler (#195847) (PR #196084)

2026-05-06 Thread via llvm-branch-commits

https://github.com/llvmbot milestoned 
https://github.com/llvm/llvm-project/pull/196084
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lldb] release/22.x: [lldb-dap] Fix crash in source request handler (#195847) (PR #196084)

2026-05-06 Thread via llvm-branch-commits

https://github.com/llvmbot created 
https://github.com/llvm/llvm-project/pull/196084

Backport fa8724beccad53be2d39d065be5db11917f94bac

Requested by: @da-viper

>From 3f2ce8546cac8adefeddb97cb4ec6348742f52f2 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike 
Date: Tue, 5 May 2026 20:20:54 +0100
Subject: [PATCH] [lldb-dap] Fix crash in source request handler (#195847)

Check optional argument source has a value before getting the source
reference.

(cherry picked from commit fa8724beccad53be2d39d065be5db11917f94bac)
---
 lldb/test/API/tools/lldb-dap/source/TestDAP_source.py | 6 ++
 lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp  | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/tools/lldb-dap/source/TestDAP_source.py 
b/lldb/test/API/tools/lldb-dap/source/TestDAP_source.py
index edf0af0bba2ba..01c28fe7a568e 100644
--- a/lldb/test/API/tools/lldb-dap/source/TestDAP_source.py
+++ b/lldb/test/API/tools/lldb-dap/source/TestDAP_source.py
@@ -32,6 +32,12 @@ def test_source(self):
 response = self.dap_server.request_source(sourceReference=0)
 self.assertFalse(response["success"], "verify invalid sourceReference 
fails")
 
+# Check only source reference in the arguments field.
+response = self.dap_server.request_custom("source", 
{"sourceReference": 0})
+self.assertFalse(response["success"], "expected failed response")
+error_format = self.get_dict_value(response, ["body", "error", 
"format"])
+self.assertIn("unknown source reference", error_format)
+
 (stackFrames, totalFrames) = 
self.get_stackFrames_and_totalFramesCount()
 frameCount = len(stackFrames)
 self.assertGreaterEqual(frameCount, 3, "verify we got up to main at 
least")
diff --git a/lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp
index 755ad206abe26..b2074e54e6be2 100644
--- a/lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/SourceRequestHandler.cpp
@@ -31,13 +31,14 @@ llvm::Expected
 SourceRequestHandler::Run(const protocol::SourceArguments &args) const {
 
   uint32_t source_ref =
-  args.source->sourceReference.value_or(args.sourceReference);
+  args.source ? args.source->sourceReference.value_or(args.sourceReference)
+  : args.sourceReference;
   const std::optional source_addr_opt =
   dap.GetSourceReferenceAddress(source_ref);
 
   if (!source_addr_opt)
 return llvm::make_error(
-llvm::formatv("Unknown source reference {}", source_ref));
+llvm::formatv("unknown source reference {}", source_ref));
 
   lldb::SBAddress address(*source_addr_opt, dap.target);
   if (!address.IsValid())

___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits