Skip to content

regression: hang with -Zsave-analysis #101505

Closed

Description

@matthiaskrgr

Code

I tried this code:

fn next_letter_position(&self, x_index: f32, y_index: f32, width: f32) -> (f32, f32) {
    let vwidth = &self.viewport.x / 2.0;

    match x_index * width {
        0.0 ... vwidth => {
            (x_index + 1.0, y_index)
        },
        _ => (0.0, y_index - 1.0)
    }
}

with rustc rustc 1.65.0-nightly (c07a8b4e0 2022-08-26) this runs in a couple ms:
rustc ./a.rs --crate-type=lib -Zsave-analysis -Ztime=yes -Ztime-passes=yes

with rustc rustc 1.65.0-nightly (3c7278846 2022-09-06) this seems to hang somewhere in save-analysis

  26,77%  librustc_driver-0f3b2583c1b011ce.so  [.] <rustc_middle::hir::map::Map>::get
  24,00%  librustc_driver-0f3b2583c1b011ce.so  [.] <rustc_middle::hir::map::Map>::get_parent_node
   5,76%  librustc_driver-0f3b2583c1b011ce.so  [.] <rustc_save_analysis::SaveContext>::get_path_res

( I killed the process after waiting for 5 minutes 🙃 )

Activity

  1. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Sep 6, 2022
  2. matthiaskrgr commented on Sep 6, 2022

    @matthiaskrgr
    MemberAuthor

    reduced:

    fn a(self) {}

    RIP -Zsave-analysis

  3. added
    S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
    A-save-analysisArea: saving results of analyses such as inference and borrowck results to a file.
    on Sep 6, 2022
  4. matthiaskrgr commented on Sep 6, 2022

    @matthiaskrgr
    MemberAuthor

    I think this is caused by #101228 cc @nnethercote

  5. self-assigned this
    on Sep 7, 2022
  6. nnethercote commented on Sep 7, 2022

    @nnethercote
    Contributor

    Clearly a well tested feature 😛 I'll take a look.

  7. nnethercote commented on Sep 7, 2022

    @nnethercote
    Contributor

    The old code looked like this:

    Node::PathSegment(seg) => match seg.res {
        Some(res) if res != Res::Err => res,
        _ => { 
            let parent_node = self.tcx.hir().get_parent_node(hir_id);
            self.get_path_res(parent_node)
        }
    },  
    

    The new code looks like this:

    Node::PathSegment(seg) => {
        if seg.res != Res::Err {
            seg.res
        } else {
            let parent_node = self.tcx.hir().get_parent_node(hir_id);
            self.get_path_res(parent_node)
        }   
    }   
    

    because seg.res is no longer optional.

    The infinite recursion happens because the get_parent_node call returns a parent_node that is the same as the hir_id. When I printed that ID out it looks like this:

    HirId { owner: DefId(0:4 ~ s[5740]::a), local_id: 5 } 
    

    An easy fix is to check if parent_node is the same as hir_id and return Res:Err if so. But I don't know if that's just papering over a deeper problem.

    @petrochenkov: Is it an underlying bug that get_parent_node can return the same node it is given?

  8. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 8, 2022
  9. added a commit that references this issue on Sep 12, 2022
  10. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-save-analysisArea: saving results of analyses such as inference and borrowck results to a file.C-bugCategory: This is a bug.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions