codelldb icon indicating copy to clipboard operation
codelldb copied to clipboard

Debugger adapter crashes in print completions

Open andrey-golubev opened this issue 3 years ago • 3 comments

OS: arch linux (rolling release) VSCode version: 1.73.1 (commit 6261075646f055b99068d3688932416f2346dd3b) CodeLLDB version: 1.7.0 Compiler: gcc 12.2.0 Debuggee: native c++

The adapter crashes consistently every time whenever I try to print something through the VSCode's Debug Console. Practically, crashes as soon as the p is typed, followed by the space. The stacktrace suggests that command completion fails.

Verbose log
configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Debug',
  program: '${workspaceFolder}/build/tests/clsc_tests',
  args: [ '--gtest_filter=*simple_tokens/besc_parser_tests.all/IDENTIFIER*' ],
  cwd: '${workspaceFolder}',
  __configurationTarget: 6,
  relativePathBase: '/home/ag/clsc'
}
liblldb: /home/ag/.vscode-oss/extensions/vadimcn.vscode-lldb-1.7.0/lldb/lib/liblldb.so
environment: {}
params: { evaluateForHovers: true, commandCompletions: true }
[2022-12-01T21:55:17.391Z DEBUG codelldb] New debug session
INFO(Python) 22:55:17 formatters: Initializing
INFO(Python) 22:55:17 formatters.rust: Initializing
[2022-12-01T21:55:17.538Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Code - OSS","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true},"type":"request","seq":1}
[2022-12-01T21:55:17.538Z DEBUG codelldb::dap_codec]  {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Debug","program":"/home/ag/clsc/build/tests/clsc_tests","args":["--gtest_filter=*simple_tokens/besc_parser_tests.all/IDENTIFIER*"],"cwd":"/home/ag/clsc","__configurationTarget":6,"relativePathBase":"/home/ag/clsc","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null,"evaluateForHovers":true,"commandCompletions":true,"reproducer":false},"__sessionId":"f3bb07d4-52a4-4f90-af8e-613df01ad222"},"type":"request","seq":2}
[2022-12-01T21:55:17.545Z DEBUG codelldb::dap_codec]  {"command":"setBreakpoints","arguments":{"source":{"name":"algorithm_tests.cpp","path":"/home/ag/clsc/tests/algorithm_tests.cpp"},"lines":[186],"breakpoints":[{"line":186}],"sourceModified":false},"type":"request","seq":3}
[2022-12-01T21:55:17.610Z DEBUG codelldb::debug_session] Debug event: 0x556fe73bbd60 Event: broadcaster = 0x556fe66aa408 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2022-12-01T21:55:17.610Z DEBUG codelldb::dap_codec]  {"command":"setBreakpoints","arguments":{"source":{"name":"besc_parser.cpp","path":"/home/ag/clsc/bes/besc_parser.cpp"},"lines":[602,607,615],"breakpoints":[{"line":602},{"line":607},{"line":615}],"sourceModified":false},"type":"request","seq":4}
[2022-12-01T21:55:17.610Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"besc_tests.cpp","path":"/home/ag/clsc/tests/besc_tests.cpp"},"lines":[214],"breakpoints":[{"line":214}],"sourceModified":false},"type":"request","seq":5}
[2022-12-01T21:55:17.610Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":6}
[2022-12-01T21:55:17.610Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":7}
[2022-12-01T21:55:17.610Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":8}
[2022-12-01T21:55:17.612Z DEBUG codelldb::debug_session] Debug event: 0x556fe7416c50 Event: broadcaster = 0x556fe66aa408 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {}
[2022-12-01T21:55:17.612Z DEBUG codelldb::dap_codec]  {"type":"response","seq":9,"command":"runInTerminal","request_seq":6,"success":true,"body":{"shellProcessId":3105}}
[2022-12-01T21:55:17.705Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":10}
[2022-12-01T21:55:17.705Z DEBUG codelldb::dap_codec]  {"command":"threads","type":"request","seq":11}
[2022-12-01T21:55:17.789Z DEBUG codelldb::dap_codec] [2022-12-01T21:55:18.065Z DEBUG codelldb::debug_session] Debug event: 0x7f4e900143d0 Event: broadcaster = 0x556fe6b073f8 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x556fe6b073c0 (pid = 9931), state = stopped}
[2022-12-01T21:55:18.065Z DEBUG codelldb::dap_codec] <-- {"seq":47,"type":"event","event":"stopped","body":{"allThreadsStopped":true,"reason":"breakpoint","threadId":9931}}
[2022-12-01T21:55:18.086Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":12}
[2022-12-01T21:55:18.086Z DEBUG codelldb::dap_codec] <-- {"seq":48,"type":"response","request_seq":12,"success":true,"command":"threads","body":{"threads":[{"id":9931,"name":"1: tid=9931 "clsc_tests""}]}}
[2022-12-01T21:55:18.093Z DEBUG codelldb::dap_codec] --> {"command":"stackTrace","arguments":{"threadId":9931,"startFrame":0,"levels":1},"type":"request","seq":13}
[2022-12-01T21:55:18.095Z DEBUG codelldb::dap_codec] <-- {"seq":49,"type":"response","request_seq":13,"success":true,"command":"stackTrace","body":{"stackFrames":[{"column":17,"id":1001,"line":214,"name":"besc_parser_tests_all_Test::TestBody()","source":{"name":"besc_tests.cpp","path":"/home/ag/clsc/tests/besc_tests.cpp"}}],"totalFrames":15}}
[2022-12-01T21:55:18.526Z DEBUG codelldb::dap_codec] --> {"command":"stackTrace","arguments":{"threadId":9931,"startFrame":1,"levels":19},"type":"request","seq":14}
[2022-12-01T21:55:18.530Z DEBUG codelldb::disassembly] libc.so.6___lldb_unnamed_symbol3141 + 128 [2022-12-01T21:55:18.530Z DEBUG codelldb::disassembly] libc.so.6__libc_start_main + 138
[2022-12-01T21:55:18.531Z DEBUG codelldb::disassembly] clsc_tests`_start + 37
[2022-12-01T21:55:18.532Z DEBUG codelldb::dap_codec] <-- {"seq":50,"type":"response","request_seq":14,"success":true,"command":"stackTrace","body":{"stackFrames":[{"column":27,"id":1002,"line":2443,"name":"void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":52,"id":1003,"line":2479,"name":"void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::)(), char const)","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":50,"id":1004,"line":2517,"name":"testing::Test::Run()","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":14,"id":1005,"line":2693,"name":"testing::TestInfo::Run()","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":31,"id":1006,"line":2811,"name":"testing::TestCase::Run()","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":46,"id":1007,"line":5177,"name":"testing::internal::UnitTestImpl::RunAllTests()","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":27,"id":1008,"line":2443,"name":"bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":52,"id":1009,"line":2479,"name":"bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::)(), char const)","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":55,"id":1010,"line":4786,"name":"testing::UnitTest::Run()","source":{"name":"gtest.cc","path":"/home/ag/clsc/external/googletest/googletest/src/gtest.cc"}},{"column":49,"id":1011,"line":2341,"name":"RUN_ALL_TESTS()","source":{"name":"gtest.h","path":"/home/ag/clsc/external/googletest/googletest/include/gtest/gtest.h"}},{"column":25,"id":1012,"line":33,"name":"main","source":{"name":"main.cpp","path":"/home/ag/clsc/tests/main.cpp"}},{"column":0,"id":1013,"line":29,"name":"___lldb_unnamed_symbol3141","presentationHint":"subtle","source":{"name":"@___lldb_unnamed_symbol3141","sourceReference":1000}},{"column":0,"id":1014,"line":44,"name":"__libc_start_main","presentationHint":"subtle","source":{"name":"@__libc_start_main","sourceReference":1001}},{"column":0,"id":1015,"line":15,"name":"_start","presentationHint":"subtle","source":{"name":"@_start","sourceReference":1002}}],"totalFrames":15}}
[2022-12-01T21:55:18.632Z DEBUG codelldb::dap_codec] --> {"command":"scopes","arguments":{"frameId":1001},"type":"request","seq":15}
[2022-12-01T21:55:18.632Z DEBUG codelldb::dap_codec] <-- {"seq":51,"type":"response","request_seq":15,"success":true,"command":"scopes","body":{"scopes":[{"expensive":false,"name":"Local","variablesReference":1016},{"expensive":false,"name":"Static","variablesReference":1017},{"expensive":false,"name":"Global","variablesReference":1018},{"expensive":false,"name":"Registers","variablesReference":1019}]}}
[2022-12-01T21:55:18.639Z DEBUG codelldb::dap_codec] --> {"command":"variables","arguments":{"variablesReference":1016},"type":"request","seq":16}
warning: (x86_64) /home/ag/clsc/build/tests/clsc_tests 0x001087df: DW_AT_specification(0x000f4862) has no decl
[2022-12-01T21:55:18.665Z DEBUG codelldb::dap_codec] <-- {"seq":52,"type":"response","request_seq":16,"success":true,"command":"variables","body":{"variables":[{"evaluateName":"this","memoryReference":"0x6030000074E0","name":"this","type":"besc_parser_tests_all_Test *const","value":"{...}","variablesReference":1020},{"evaluateName":"param","memoryReference":"0x7FFFFFFFDB40","name":"param","type":"std::pair<clsc::bes::token_stream, std::basic_string<char, std::char_traits, std::allocator<> > >","value":"{...}","variablesReference":1021},{"evaluateName":"tokin","memoryReference":"0x7FFFFFFFDAB0","name":"tokin","type":"clsc::bes::token_stream &","value":"{...}","variablesReference":1022},{"evaluateName":"raw_program","memoryReference":"0x7FFFFFFFDAB8","name":"raw_program","type":"const std::basic_string<char, std::char_traits, std::allocator<> > &","value":"{_M_string_length:1}","variablesReference":1023},{"evaluateName":"parser","memoryReference":"0x7FFFFFFFDAE0","name":"parser","type":"clsc::bes::parser","value":"{m_in:0x00007fffffffdb40, m_raw_program:0x00007fffffffdb58}","variablesReference":1024}]}}
[2022-12-01T21:55:19.675Z DEBUG codelldb::dap_codec] --> {"command":"evaluate","arguments":{"expression":"clsc::bes::token_stream","frameId":1001,"context":"hover"},"type":"request","seq":17}
ERROR(Python) 22:55:19 codelldb: Traceback (most recent call last):
File "/home/ag/.vscode-oss/extensions/vadimcn.vscode-lldb-1.7.0/adapter/codelldb.py", line 152, in evaluate
value = evaluate_in_context(pycode, is_simple_expr, context)
File "/home/ag/.vscode-oss/extensions/vadimcn.vscode-lldb-1.7.0/adapter/codelldb.py", line 288, in evaluate_in_context
return eval(code, eval_globals, eval_locals)
File "", line 1, in 
File "/home/ag/.vscode-oss/extensions/vadimcn.vscode-lldb-1.7.0/adapter/codelldb.py", line 269, in missing
raise VariableNotFound(name)
codelldb.VariableNotFound: Variable 'clsc::bes::token_stream' not found

[2022-12-01T21:55:19.677Z ERROR codelldb::debug_session] Variable 'clsc::bes::token_stream' not found [2022-12-01T21:55:19.677Z DEBUG codelldb::dap_codec] <-- {"seq":53,"type":"response","request_seq":17,"success":false,"command":"","message":"Variable 'clsc::bes::token_stream' not found","show_user":true} [2022-12-01T21:55:22.492Z DEBUG codelldb::dap_codec] --> {"command":"completions","arguments":{"frameId":1001,"text":"p","column":2,"line":1},"type":"request","seq":18} [2022-12-01T21:55:22.492Z DEBUG codelldb::dap_codec] <-- {"seq":54,"type":"response","request_seq":18,"success":true,"command":"completions","body":{"targets":[{"label":"p"}]}} [2022-12-01T21:55:23.399Z DEBUG codelldb::dap_codec] --> {"command":"completions","arguments":{"frameId":1001,"text":"p r","column":4,"line":1},"type":"request","seq":19} Received signal: SIGSEGV 0: codelldb::hook_crashes::handler 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: ZN4lldb20SBCommandInterpreter32HandleCompletionWithDescriptionsEPKcS2_S2_iiRNS_12SBStringListES4 44: _ZN4lldb20SBCommandInterpreter16HandleCompletionEPKcS2_S2_iiRNS_12SBStringListE 45: __cpp_closure_10031222636214441753 46: lldb::sb::sbcommandinterpreter::SBCommandInterpreter::handle_completions 47: codelldb::debug_session::DebugSession::handle_request_args 48: codelldb::debug_session::DebugSession::handle_request 49: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll 50: tokio::runtime::task::harness::Harness<T,S>::poll 51: std::thread::local::LocalKey<T>::with 52: tokio::task::local::LocalSet::tick 53: <tokio::task::local::LocalSet as core::future::future::Future>::poll 54: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll 55: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll 56: tokio::park::thread::CachedParkThread::block_on 57: tokio::runtime::thread_pool::ThreadPool::block_on 58: tokio::runtime::Runtime::block_on 59: entry 60: codelldb::main 61: std::sys_common::backtrace::__rust_begin_short_backtrace 62: std::rt::lang_start::{{closure}} 63: std::rt::lang_start_internal 64: main 65: 66: __libc_start_main 67: _start

Debug adapter exit code=255, signal=null.

The stacktrace (see verbose log) kind of hints at roughly this place. Given that it's an unsafe c++ block, that might indeed have some magic tricks happening in there.

andrey-golubev avatar Dec 01 '22 21:12 andrey-golubev

Yeah, LLDB is known to do that sometimes. Seems to be some sort of incompatibility with gcc-emitted debug info.
You can disable auto-evaluation via lldb.commandCompletions and lldb.evaluateForHovers. https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md#advanced

vadimcn avatar Dec 02 '22 00:12 vadimcn

Oh, thanks for the lldb.evaluateForHovers! Tried messing with lldb.commandCompletion (before submitting a bug) but it didn't seem to help. Will try the other one.

andrey-golubev avatar Dec 02 '22 07:12 andrey-golubev

Finally got to testing this again:

Disabling lldb.commandCompletions seems to help. Somehow (?) it didn't work before when I toggled that option but oh well. Guessing that would do as a workaround for the time being.

andrey-golubev avatar Dec 07 '22 19:12 andrey-golubev