Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to read value of recursive enum when debugging with lldb #118331

Open
clems4ever opened this issue Nov 26, 2023 · 9 comments
Open

Unable to read value of recursive enum when debugging with lldb #118331

clems4ever opened this issue Nov 26, 2023 · 9 comments
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences

Comments

@clems4ever
Copy link

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.

@clems4ever clems4ever added the C-bug Category: This is a bug. label Nov 26, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 26, 2023
@GuyResh
Copy link

GuyResh commented Jan 24, 2024

Same issue with VecDeque:
{...}
: <error: invalid value object>
...
[raw] alloc::collections::vec_deque::VecDeque<u64,alloc::alloc::Global>

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 18, 2024
@vlovich
Copy link

vlovich commented Apr 22, 2024

Seeing this as well. The VecDequeu issue is particularly bad since it's a std library container.

@8thMage
Copy link

8thMage commented Apr 29, 2024

I tracked down the issue to this change:
502df1b
Where the capacity is no longer stored as a usize, but it's stored as a pointer.

code lldb rust didn't handle it, and the change is easy from:
self.cap = gcm(self.valobj, 'buf', 'cap').GetValueAsUnsigned()
to:
self.cap = gcm(self.valobj, 'buf', 'cap', "0").GetValueAsUnsigned()
I'll create a pull request.

8thMage pushed a commit to 8thMage/codelldb that referenced this issue Apr 29, 2024
in this issue: rust-lang/rust#118331 there's shown a bug where vecdeque doesn't show the values inside a vecdeque. As commented by me in the issue, this change rust-lang/rust@502df1b broke the current formatter, as it transformed capacity from a POD to a struct. This pr reads the capacity from that struct.
8thMage pushed a commit to 8thMage/codelldb that referenced this issue Apr 29, 2024
in this issue: rust-lang/rust#118331 there's shown a bug where vecdeque doesn't show the values inside a vecdeque. As commented by me in the issue, this change rust-lang/rust@502df1b broke the current formatter, as it transformed capacity from a POD to a struct. This pr reads the capacity from that struct.
@incapdns
Copy link

incapdns commented May 3, 2024

The same thing is happening to me, can anyone tell me if there is any workaround or if it is also happening in the stable version?

8thMage pushed a commit to 8thMage/codelldb that referenced this issue May 11, 2024
in this issue: rust-lang/rust#118331 there's shown a bug where vecdeque doesn't show the values inside a vecdeque. As commented by me in the issue, this change rust-lang/rust@502df1b broke the current formatter, as it transformed capacity from a POD to a struct. This pr reads the capacity from that struct.
@mschnell1
Copy link

The problem still persists. With the current nightly build I get the message <error: invalid value object>, while with the stable build the content of the vector is shown.

@elenakrittik
Copy link

@mschnell1 See vadimcn/codelldb#1142. I don't know if it's a CodeLLDB or Rust issue, though.

@joshuataylor
Copy link

joshuataylor commented Sep 22, 2024

Seeing this with Strings on rustc 1.83.0-nightly (1d68e6dd1 2024-09-21), last build that worked was rustc 1.82.0-nightly (41dd149fd 2024-08-11).

I'm seeing this in RustRover, tried in VSCode and came across this issue.

Doesn't happen with stable (rustc 1.81.0 (eeb90cda1 2024-09-04)).

rust-lldb seems to work fine though.

Test file setup

src/main.rs:

fn main() {
    let b = String::from("hello!");
    println!("Hello, world!");
}

Run rust-lldb

cargo build

How to use rust-lldb

One liner:

rust-lldb --batch -o "breakpoint set --file main.rs --line 3" -o "run" -o "v b" ./target/debug/testd

Otherwise:

rust-lldb target/debug/testd
  1. Set a breakpoint
breakpoint set --file main.rs --line 3
  1. Run the program
run
  1. View the breakpoint
v b
  1. Expected output:
(alloc::string::String) b = "hello!" {
  vec = size=6 {
    [0] = 'h'
    [1] = 'e'
    [2] = 'l'
    [3] = 'l'
    [4] = 'o'
    [5] = '!'
  }
}

lldb_providers

It might be an issue with lldb_providers, these show the formatted output.

  1. lldb_providers.py
  2. rust_types.py

@alebairos
Copy link

The problem still persists. With the current nightly build I get the message <error: invalid value object>, while with the stable build the content of the vector is shown.

yep. Reproduced here. Days to find out when I finally switched back to stable.

stable-x86_64-unknown-linux-gnu unchanged - rustc 1.81.0 (eeb90cd 2024-09-04)
nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.83.0-nightly (14f303b 2024-10-04)

@mschnell1
Copy link

mschnell1 commented Oct 5, 2024

I don't know if this is related anyhow....
Debugging issue,. when debugging using VSCode (I suppose I have all current versions, and stable rustc).
I have code with variable name overriding (multiple let xyz= .... e.g. let xy = fxy(); let xy = xy.unwrap(); )
The debugger mostly shows the value of the first occurrence of a variable (-name) and not the one in scope with the breakpoint. (Of course the outdated content often is overridden at that point and just rubbish)

Adjective-Object pushed a commit to Adjective-Object/good-fences-rs-core that referenced this issue Oct 16, 2024
This is to work around [this issue](rust-lang/rust#118331) in the rust debugger
Adjective-Object pushed a commit to Adjective-Object/good-fences-rs-core that referenced this issue Oct 31, 2024
This is to work around [this issue](rust-lang/rust#118331) in the rust debugger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-debugging Working group: Bad Rust debugging experiences
Projects
None yet
Development

No branches or pull requests