Skip to content

Fix: added UnionSyntheticProvider for LLDB#154055

Open
Mottl wants to merge 1 commit intorust-lang:mainfrom
Mottl:union-lldb-formatter
Open

Fix: added UnionSyntheticProvider for LLDB#154055
Mottl wants to merge 1 commit intorust-lang:mainfrom
Mottl:union-lldb-formatter

Conversation

@Mottl
Copy link
Copy Markdown

@Mottl Mottl commented Mar 18, 2026

This PR fixes crashing of rust-lldb when union inside union holds variants which are aligned differently.

The following code will crash rust-lldb while inspecting AlignedStruct:

use std::mem::ManuallyDrop;

#[repr(C, align(8))]
struct AlignedStruct {
    data: [u8; 16],
}

union SomeUnion {
    a: (),
    b: ManuallyDrop<AlignedStruct>,
}

fn main() {
    let s = SomeUnion {
        b: ManuallyDrop::new(AlignedStruct {
            data: *b"Hello World\0\0\0\0\0",
        }),
    };
    println!("break here"); // breakpoint here and expand `s`
}

Trying to expand s will crash lldb with SIGSEGV

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 18, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 18, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Mark-Simulacrum

Copy link
Copy Markdown
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? @Walnut356, can you take a look and see if this makes sense?

View changes since this review


addr = child.GetLoadAddress()
if addr == LLDB_INVALID_ADDRESS:
return True # can't check — let LLDB decide
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say more about this? If LLDB can decide, why can't it always do the right thing? Does this still leave the bug in place for some set of cases?

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

Failed to set assignee to Walnut356: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@Walnut356
Copy link
Copy Markdown
Contributor

Walnut356 commented Mar 28, 2026

I was not able to replicate the crash. I tried compiling your example program, and for both *-gnu and *-msvc I ran it through

  • LLDB 21.1.4 and 21.1.8 with Rust's built-in visualizers (rustc 1.90.0, 1.93.9, and 1.94.0)
  • LLDB 21.1.4 and 22.1.2 and with my own custom visualizers
  • CodeLLDB 1.12.0 (LLDB version 21.1.7-codelldb, defers to rust's built-in visualizers)

CLI LLDB simply omitted the a field in all cases, CodeLLDB reported it as error: invalid value object for *-gnu targets, but otherwise didn't complain. There were no issues with the b field

If possible, can you provide the following:

  • LLDB Version
  • rustc version
  • target triple you're compiling for
  • any debug adapter you are using and its version (e.g. CodeLLDB, rustrover debugger)

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 5, 2026

☔ The latest upstream changes (presumably #154824) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants