Skip to content

Panic and debug session hang caused by re-entrant events when executing LLDB custom Python command #1293

@johngladp

Description

@johngladp

OS: Windows on client, Ubuntu server 22.04 on remote.
VSCode version: 1.101.1
CodeLLDB version: 1.11.5
Compiler: clang++ v19.1.7
Debuggee: Linux x64 executable.

  • Panic caused by LLDB sending a breakpoint event whilst a custom Python command is still executing:
    "thread 'main' panicked at adapter/codelldb/src/debug_session/breakpoints.rs:644:16:
    Cannot start a runtime from within a runtime. This happens because a function (like block_on) attempted to block the current thread while the thread is being used to drive asynchronous tasks."
  • The panic hangs the debug session. VSCode doesn't ever jump to the breakpoint that has been hit.
  • The breakpoint in question is on the first line of main(). It seems I can place breakpoint elsewhere in the code, this is a race condition, the later in the processes execution the breakpoint occurs the less likely the issue is to occur, presumably because this is a race to exit the Python command before the breakpoint event is fired.
  • Adding "debugger.SetAsync(True)" to the beginning of the Python command mostly remedies the issue but I suspect we're just altering the "race conditions", not actually addressing the issue.
  • The custom Python command where the issue occurs has called target.Launch(). We see "Executing Launch...", the "DONE" message at the end of the command is never printed:

Image

Image

  • Fragment of the launch.json being used:
    Image
Verbose log
  
thread 'main' panicked at adapter/codelldb/src/debug_session/breakpoints.rs:644:16:
Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: tokio::runtime::context::runtime::enter_runtime
   3: codelldb::debug_session::breakpoints::::init_bp_actions::{{closure}}
   4: lldb::sb::sbbreakpoint::SBBreakpoint::set_callback::callback_thunk
   5: _ZN4lldb25SBBreakpointCallbackBaton28PrivateBreakpointHitCallbackEPvPN12lldb_private24StoppointCallbackContextEmm
   6: 
   7: 
   8: 
   9: 
  10: 
  11: 
  12: 
  13: 
  14: 
  15: 
  16: 
  17: _ZN4lldb8SBTarget6LaunchERNS_12SBLaunchInfoERNS_7SBErrorE
  18: 
  19: 
  20: PyObject_Call
  21: _PyEval_EvalFrameDefault
  22: 
  23: 
  24: 
  25: 
  26: 
  27: 
  28: 
  29: 
  30: _ZN4lldb20SBCommandInterpreter13HandleCommandEPKcRNS_18SBExecutionContextERNS_21SBCommandReturnObjectEb
  31: _ZN4lldb20SBCommandInterpreter13HandleCommandEPKcRNS_21SBCommandReturnObjectEb
  32: __cpp_closure_17879338975969274467
  33: lldb::strings::with_cstr
  34: lldb::sb::sbcommandinterpreter::SBCommandInterpreter::handle_command
  35: codelldb::debug_session::DebugSession::exec_commands
  36: codelldb::debug_session::launch::::complete_launch
  37: codelldb::debug_session::launch::::handle_launch::{{closure}}
  38: codelldb::debug_session::DebugSession::handle_request::{{closure}}
  39: tokio::runtime::task::core::Core::poll
  40: tokio::runtime::task::raw::poll
  41: tokio::task::local::LocalSet::tick
  42: ::poll
  43: codelldb::run_debug_session::{{closure}}
  44: tokio::runtime::context::runtime::enter_runtime
  45: tokio::runtime::runtime::Runtime::block_on
  46: codelldb::debug_server
  47: codelldb::main

Full trace - PANIC callstack is on line 140:

Verbose logging on.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions