rust-lang / rust-lang/rust

Unable to read value of recursive enum when debugging with lldb

Open
#118,331 9 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug T-compiler WG-debugging
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Hello,

I'm currently facing an issue preventing me from debugging some code where recursive enums are involved. I cannot read the value from the debugger (LLDB using the extension from Vadim Chugunov on VSCode), instead I get the following error message in vscode: "<error: invalid value object>". Other types are readable, even non-recursive enums.

A picture is worth a thousand words so here it is:

screenshot-2023-11-26T19:13:48+01:00

The code to reproduce is simple:

#[derive(Debug)]
enum Test{
    Test(Box<Test>),
    Tail
}

fn main() {
    let t = Test::Test(Box::new(Test::Tail));

    println!("{:?}", t);
}

Ideally, I would be able to troubleshoot the content of the variable.

Here is the version of rust I'm using:

$ rustc --version --verbose
rustc 1.74.0 (79e9716c9 2023-11-13)
binary: rustc
commit-hash: 79e9716c980570bfd1f666e3b16ac583f0168962
commit-date: 2023-11-13
host: x86_64-unknown-linux-gnu
release: 1.74.0
LLVM version: 17.0.4

I have the same problem with the nightly

$ rustc --version --verbose
rustc 1.76.0-nightly (37b2813a7 2023-11-24)
binary: rustc
commit-hash: 37b2813a7be580ef59048a6bd08444c79e5cc97f
commit-date: 2023-11-24
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

I think this might not be a bug but rather a use case not yet properly handled by rust and/or lldb. Does anyone know?

Thanks in advance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the recursive-enum example with rustc, LLDB, and the VSCode extension, then inspect how the debugger presents the variable. Done means the recursive enum's value and contents can be read in the debugger instead of showing "<error: invalid value object>".

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.