Skip to content

fix(debuginfo): disable overflow check for recursive non-enum types #144407

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

Merged
merged 1 commit into from
Jul 29, 2025

Conversation

godzie44
Copy link
Contributor

@godzie44 godzie44 commented Jul 24, 2025

Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures.

For example see #143241 (#143241 (comment)). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a hir_analysis_recursive_generic_parameter for that).

closes #143241

@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
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

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2025
@fee1-dead
Copy link
Member

r? compiler

@rustbot rustbot assigned petrochenkov and unassigned fee1-dead Jul 24, 2025
@fee1-dead
Copy link
Member

cc @wesleywiser and @adwinwhite, this fixes regression #143241 most possibly caused by #138599

This should probably be tested

@tmiasko
Copy link
Contributor

tmiasko commented Jul 24, 2025

In principle, the original issue also applies to structs. For example:

use std::marker::PhantomData;

pub struct AB<T: 'static> {
    pub a: PhantomData<T>,
    pub b: *const AB<(T, T)>,
}

fn main() {
    std::hint::black_box(AB::<()> { a: PhantomData, b: std::ptr::null() });
}

@godzie44
Copy link
Contributor Author

Sad, i miss this example before.

Btw, without the pub a: PhantomData<T> field, the hir_analysis_recursive_generic_parameter diagnostic is triggered and example are not complied. There may be some inconsistency here, according to hir_analysis_recursive_generic_parameter check?

@petrochenkov
Copy link
Contributor

r? @wesleywiser as the reviewer of #138599

@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

wesleywiser is not on the review rotation at the moment.
They may take a while to respond.

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

Can you add a codegen regression test that verifies we emit the appropriate amount of debuginfo for the minimal repro you found?

https://github.com/rust-lang/rust/blob/master/tests/codegen-llvm/debuginfo-inline-callsite-location.rs might be a helpful example.

@rustbot rustbot 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 Jul 26, 2025
@godzie44 godzie44 force-pushed the godzie44/fix_dwarf_inconsistency branch from 1bef605 to 49eda8e Compare July 27, 2025 11:42
@godzie44
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2025
@wesleywiser
Copy link
Member

Thanks @godzie44!

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 28, 2025

📌 Commit 49eda8e has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Jul 29, 2025
…istency, r=wesleywiser

fix(debuginfo): disable overflow check for recursive non-enum types

Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures.

For example see rust-lang#143241 (rust-lang#143241 (comment)). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a `hir_analysis_recursive_generic_parameter` for that).

closes rust-lang#143241
bors added a commit that referenced this pull request Jul 29, 2025
Rollup of 14 pull requests

Successful merges:

 - #144022 (Implementation: `#[feature(sync_nonpoison)]`, `#[feature(nonpoison_mutex)]`)
 - #144167 (Document why `Range*<&T> as RangeBounds<T>` impls are not `T: ?Sized`, and give an alternative.)
 - #144407 (fix(debuginfo): disable overflow check for recursive non-enum types)
 - #144451 (fix: Reject upvar scrutinees for `loop_match`)
 - #144482 (Add explicit download methods to download module in bootstrap)
 - #144500 (thread name in stack overflow message)
 - #144511 (tidy: increase performance of auto extra checks feature)
 - #144586 (Update wasi-sdk to 27.0 in CI)
 - #144599 (bootstrap: enable tidy auto extra checks on tools profile)
 - #144600 (Ensure external paths passed via flags end up in rustdoc depinfo)
 - #144609 (feat: Right align line numbers)
 - #144623 (miri subtree update)
 - #144626 (cc dependencies: clarify comment)
 - #144627 (Add a test case for the issue #129882)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 29, 2025
Rollup of 13 pull requests

Successful merges:

 - #144022 (Implementation: `#[feature(sync_nonpoison)]`, `#[feature(nonpoison_mutex)]`)
 - #144167 (Document why `Range*<&T> as RangeBounds<T>` impls are not `T: ?Sized`, and give an alternative.)
 - #144407 (fix(debuginfo): disable overflow check for recursive non-enum types)
 - #144451 (fix: Reject upvar scrutinees for `loop_match`)
 - #144482 (Add explicit download methods to download module in bootstrap)
 - #144500 (thread name in stack overflow message)
 - #144511 (tidy: increase performance of auto extra checks feature)
 - #144599 (bootstrap: enable tidy auto extra checks on tools profile)
 - #144600 (Ensure external paths passed via flags end up in rustdoc depinfo)
 - #144609 (feat: Right align line numbers)
 - #144623 (miri subtree update)
 - #144626 (cc dependencies: clarify comment)
 - #144627 (Add a test case for the issue #129882)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b3962e8 into rust-lang:master Jul 29, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 29, 2025
rust-timer added a commit that referenced this pull request Jul 29, 2025
Rollup merge of #144407 - godzie44:godzie44/fix_dwarf_inconsistency, r=wesleywiser

fix(debuginfo): disable overflow check for recursive non-enum types

Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures.

For example see #143241 (#143241 (comment)). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a `hir_analysis_recursive_generic_parameter` for that).

closes #143241
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incomplete DWARF debug info in Rust 1.88
7 participants