codelldb icon indicating copy to clipboard operation
codelldb copied to clipboard

Extension crashes when stepping through the code

Open hpesoj opened this issue 3 years ago • 4 comments

OS: Windows 10 64-bit VSCode version: 1.62.3 (user setup) CodeLLDB version: v1.6.10 Compiler: Android (7284624, based on r416183b) clang version 12.0.5 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee) Debuggee: ARMv8 (64-bit) -O0 -g

I am debugging remotely on an Android device by running the executable first and attaching to it.

The extension crashed moments after stopping because of a SIGSEGV (it had previously stopped at an arbitrary line since I attached to the process, and I continued). This happens sporadically, either when stopping because of a signal, stopping at a breakpoint, or when stepping through the code (I believe always when stepping into or up, so changing frame).

I will turn on verbose debugging and report when this happens again, but this may enough to work with for now.

configuration: {
  name: 'Attach to Native Tests (ARMv8)',
  type: 'lldb',
  request: 'launch',
  initCommands: [
    'platform select remote-android',
    'platform connect connect://localhost:1234'
  ],
  targetCreateCommands: [ 'target create build/debug/armv8/(redacted)' ],
  processCreateCommands: [ 'process attach --name (redacted) --waitfor' ],
  __configurationTarget: 5,
  custom: true,
  relativePathBase: '/(redacted)'
}
Listening on port 44151
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/45F7FBFE-9455-A458-4A50-347C4A5BC883/libsync.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/8E2F4272-9D82-2CEF-A46D-C69DF3FEC722/liblog.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/EC2E2500-8B28-33D4-D729-92FE679927ED/libm.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/6178CD03-EC04-90FC-06DE-BA3FC0AF3BE6/libdl.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/E380ACAB-89C9-F3F1-474C-F54BBEB32D96/libc++.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/11E08B66-ECE7-A36D-381A-71FA2A134A73/ld-android.so No LZMA support found for reading .gnu_debugdata section
warning: (aarch64) /(redacted)/.lldb/module_cache/remote-android/.cache/63225438-125D-CDBC-26BB-8CB1C5B1CC5A/libnetd_client.so No LZMA support found for reading .gnu_debugdata section
ERROR(Python) 11:18:04 codelldb: Traceback (most recent call last):
  File "/(redacted)/.vscode-server/extensions/vadimcn.vscode-lldb-1.6.10/adapter/codelldb.py", line 152, in evaluate
    value = evaluate_in_context(pycode, is_simple_expr, context)
  File "/(redacted)/.vscode-server/extensions/vadimcn.vscode-lldb-1.6.10/adapter/codelldb.py", line 288, in evaluate_in_context
    return eval(code, eval_globals, eval_locals)
  File "<input>", line 1, in <module>
  File "/(redacted)/.vscode-server/extensions/vadimcn.vscode-lldb-1.6.10/adapter/codelldb.py", line 269, in __missing__
    raise VariableNotFound(name)
codelldb.VariableNotFound: Variable 'this' not found

[2021-12-02T11:18:04.487Z ERROR codelldb::debug_session] Variable 'this' not found
ERROR(Python) 11:18:05 codelldb: Traceback (most recent call last):
  File "/(redacted)/.vscode-server/extensions/vadimcn.vscode-lldb-1.6.10/adapter/codelldb.py", line 135, in compile_code
    pycode = compile(expr, filename, 'eval')
  File "<input>", line 1
    0__frame_vars["x000000000009bc48"]
     ^
SyntaxError: invalid decimal literal

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/(redacted)/.vscode-server/extensions/vadimcn.vscode-lldb-1.6.10/adapter/codelldb.py", line 137, in compile_code
    pycode = compile(expr, filename, 'exec')
  File "<input>", line 1
    0__frame_vars["x000000000009bc48"]
     ^
SyntaxError: invalid decimal literal

[2021-12-02T11:18:05.870Z ERROR codelldb::debug_session] invalid decimal literal (<input>, line 1)
[2021-12-02T11:18:08.529Z ERROR codelldb::handles] Parent/key combination is not unique (None/[1,0])
[2021-12-02T11:18:13.271Z ERROR codelldb::handles] Parent/key combination is not unique (None/[1,0])
Received signal: SIGSEGV
   0: codelldb::hook_crashes::handler
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: _ZN4lldb7SBFrame23GetValueForVariablePathEPKcNS_16DynamicValueTypeE
  18: _ZN4lldb7SBFrame23GetValueForVariablePathEPKc
  19: <unknown>
  20: <unknown>
  21: _PyObject_Call
  22: _PyEval_EvalFrameDefault
  23: <unknown>
  24: _PyFunction_Vectorcall
  25: <unknown>
  26: _PyEval_EvalFrameDefault
  27: _PyFunction_Vectorcall
  28: <unknown>
  29: _PyEval_EvalFrameDefault
  30: _PyFunction_Vectorcall
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: <unknown>
  36: _PyEval_EvalFrameDefault
  37: <unknown>
  38: PyEval_EvalCode
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: _PyEval_EvalFrameDefault
  43: _PyFunction_Vectorcall
  44: <unknown>
  45: _PyEval_EvalFrameDefault
  46: _PyFunction_Vectorcall
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: codelldb::python::PythonInterface::evaluate
  52: codelldb::debug_session::variables::<impl codelldb::debug_session::DebugSession>::evaluate_expr_in_frame
  53: codelldb::debug_session::variables::<impl codelldb::debug_session::DebugSession>::handle_evaluate_expression
  54: codelldb::debug_session::DebugSession::handle_request_args
  55: codelldb::debug_session::DebugSession::handle_request
  56: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
  57: tokio::runtime::task::core::CoreStage<T>::poll
  58: tokio::runtime::task::harness::Harness<T,S>::poll
  59: std::thread::local::LocalKey<T>::with
  60: tokio::task::local::LocalSet::tick
  61: <tokio::task::local::LocalSet as core::future::future::Future>::poll
  62: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  63: tokio::park::thread::CachedParkThread::block_on
  64: tokio::runtime::thread_pool::ThreadPool::block_on
  65: tokio::runtime::Runtime::block_on
  66: entry
  67: codelldb::main
  68: std::sys_common::backtrace::__rust_begin_short_backtrace
  69: std::rt::lang_start::{{closure}}
  70: std::rt::lang_start_internal
  71: main
  72: __libc_start_main
  73: _start

Debug adapter exit code=255, signal=null.

hpesoj avatar Dec 02 '21 11:12 hpesoj

Looks like a crash deep in the guts of lldb. Not much I can do about that, other than eventually upgrade to the next lldb version when a new one comes out...

Looks like this happened when automatically evaluating an expression on hover, though. You can try disabling that via "lldb.evaluateForHovers" setting. Maybe also disable "lldb.commandCompletions".

vadimcn avatar Dec 03 '21 17:12 vadimcn

@vadimcn Could this issue caused by incompatible lldb shared library ? I just met similar issue on Linux x64, debugging x64 native C++ code, and command line lldb nearly never crash, but CodeLLDB with Clagnd plugin in VSCode will surely crash in a determined file position.

I just read the doc, https://github.com/vadimcn/vscode-lldb/blob/master/MANUAL.md#alternate-lldb-backends and search other issues in this repo, and now I know CodeLLDB does not require lldb executable, but the lldb shared library, and it is bundled a "I don't know" version of liblldb.so . What I do to solve my problem is 3 thing:

  1. install clang14.0.0 and lldb 14.0.0 (under ubuntu 20.04, with apt)
  2. re-compile whole projec with new compiler
  3. specify lldb shared library location and lldb-server-14.0.0 path in settings.json , and align other compiler related values:
    "lldb.library": "/usr/lib/llvm-14/lib/liblldb.so.1",
    "lldb.adapterEnv": {"LLDB_DEBUGSERVER_PATH": "/usr/lib/llvm-14/bin/lldb-server-14.0.0"}

图片

  1. Redo the debugging with CodeLLDB

Then the debugging crash disappeared. Hope this can help people with similar problems.

zchrissirhcz avatar Dec 07 '21 15:12 zchrissirhcz

Not so much "incompatible" as "buggy". It's quite possible that something got been fixed in lldb 14 compared to lldb 13 (which is what current codelldb bundles).

vadimcn avatar Dec 07 '21 17:12 vadimcn

@vadimcn note that lldb-13 crashes in a QT application when a breakpoint is set in some inherited QObject class. https://github.com/llvm/llvm-project/issues/52986

Unfortunately, for me it is a mandatory to use lldb version 14 or higher.

voiza avatar Feb 22 '22 14:02 voiza