Skip to content

Commit 98f2eb7

Browse files
jeffreytan81jeffreytan81
andauthored
Fix StartDebuggingRequestHandler/ReplModeRequestHandler in lldb-dap (#104824)
`SBCommand::AddCommand()` requires `SBCommandPluginInterface` to be heap based because it will be stored inside `std::shared_ptr<lldb::SBCommandPluginInterface>` later for reference counting. But lldb-dap passes `StartDebuggingRequestHandler/ReplModeRequestHandler` static function pointer to it which will cause corruption later during destruction. This PR fixes this issue by making these two handler heap based. Co-authored-by: jeffreytan81 <[email protected]>
1 parent 2405253 commit 98f2eb7

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lldb/tools/lldb-dap/DAP.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ struct DAP {
192192
std::mutex call_mutex;
193193
std::map<int /* request_seq */, ResponseCallback /* reply handler */>
194194
inflight_reverse_requests;
195-
StartDebuggingRequestHandler start_debugging_request_handler;
196-
ReplModeRequestHandler repl_mode_request_handler;
197195
ReplMode repl_mode;
198196
std::string command_escape_prefix = "`";
199197
lldb::SBFormat frame_format;

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,12 @@ void request_initialize(const llvm::json::Object &request) {
16271627
"lldb-dap", "Commands for managing lldb-dap.");
16281628
if (GetBoolean(arguments, "supportsStartDebuggingRequest", false)) {
16291629
cmd.AddCommand(
1630-
"startDebugging", &g_dap.start_debugging_request_handler,
1630+
"startDebugging", new StartDebuggingRequestHandler(),
16311631
"Sends a startDebugging request from the debug adapter to the client "
16321632
"to start a child debug session of the same type as the caller.");
16331633
}
16341634
cmd.AddCommand(
1635-
"repl-mode", &g_dap.repl_mode_request_handler,
1635+
"repl-mode", new ReplModeRequestHandler(),
16361636
"Get or set the repl behavior of lldb-dap evaluation requests.");
16371637

16381638
g_dap.progress_event_thread = std::thread(ProgressEventThreadFunction);

0 commit comments

Comments
 (0)