Skip to content

rust 1.57.0 regressed DWARF for trait objects #93164

New issue

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

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

Already on GitHub? # to your account

Closed
tromey opened this issue Jan 21, 2022 · 4 comments
Closed

rust 1.57.0 regressed DWARF for trait objects #93164

tromey opened this issue Jan 21, 2022 · 4 comments
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tromey
Copy link
Contributor

tromey commented Jan 21, 2022

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.

@tromey tromey added the C-bug Category: This is a bug. label Jan 21, 2022
@michaelwoerister
Copy link
Member

Hi @tromey, thanks for reporting the bug!

The regression was probably introduced by me in #89597. I'll look into it.

@michaelwoerister michaelwoerister added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 24, 2022
@michaelwoerister michaelwoerister self-assigned this Jan 24, 2022
@michaelwoerister michaelwoerister added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jan 25, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 25, 2022
@apiraino
Copy link
Contributor

apiraino commented Feb 3, 2022

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 3, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 9, 2022
…debuginfo-regression, r=wesleywiser

debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in rust-lang#89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? `@wesleywiser`

This PR should fix issue rust-lang#93164.
~~The PR is blocked on rust-lang#93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 9, 2022
…debuginfo-regression, r=wesleywiser

debuginfo: Fix DW_AT_containing_type vtable debuginfo regression

This PR brings back the `DW_AT_containing_type` attribute for vtables after it has accidentally been removed in rust-lang#89597.

It also implements a more accurate description of vtables. Instead of describing them as an array of void pointers, the compiler will now emit a struct type description with a field for each entry of the vtable.

r? ``@wesleywiser``

This PR should fix issue rust-lang#93164.
~~The PR is blocked on rust-lang#93154 because both of them modify the `codegen/debug-vtable.rs` test case.~~
@tromey
Copy link
Contributor Author

tromey commented Mar 14, 2022

FWIW I can confirm this seems to be fixed in nightly.

@michaelwoerister
Copy link
Member

Great! There's a test now that should prevent this from regressing again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants