Skip to content

rust 1.57.0 regressed DWARF for trait objects #93164

Closed

Description

I noticed this problem when running gdb's test suite after the 1.58 release, so I tried various earlier releases and found that the regression entered in 1.57.0.

The test case is a basic one from the gdb test suite:

// Copyright (C) 2017-2022 Free Software Foundation, Inc.

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#![allow(warnings)]

pub trait T {
}

impl T for f64 {
}

impl T for u8 {
}

pub fn main() {
    let d = 23.5f64;
    let u = 23u8;

    let td = &d as &T;
    let tu = &u as &T;

    println!("");               // set breakpoint here
}

The test suite then proceeds to check for the Rust DWARF extension by running readelf and looking for DW_AT_containing_type. With 1.56.0, this passes, but with 1.57.0, this is not found.

You can test it by compiling like:

$ rustc -g traits.rs
$ readelf -wi ./traits | grep DW_AT_containing

FWIW this functionality landed in ae4cc6069626206b493caf6b1158d3d5d601bbc7. Looking at it now, I see that it did not include a test that checked to verify that the desired DWARF was generated. So, it's understandable that this could regress.

This particular DWARF extension is useful when examining trait objects. It lets a debugger find the correct type at runtime.

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

Metadata

Labels

A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions