Skip to content

Debuginfo for niche-layout enums can be corrupted due to duplicate type names #84670

Closed
@wesleywiser

Description

@wesleywiser

Niche layout enum variants do not get distinct type names that include type parameters which can cause duplicate type names for variants like Option::Some. This in turn will causes debugger to randomly pick one of the various type layouts when inspecting values which can cause invalid results.

fn main() {
    let a = Some(&1u8);
    let b = Some(&2u16);
    let c = Some(&3u32);
    let d = Some(&4u64);
    let e = Some(&5i8);
    let f = Some(&6i64);
    
    std::process::exit(0); // bp here
}

image

Notice the values for a, b and c are totally wrong because they are using the layout for Option<&i64>::Some. The types for the other variables are also wrong but that doesn't happen to cause issues in this particular instance.

Metadata

Metadata

Assignees

Labels

A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-layoutArea: Memory layout of typesC-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: Windows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions