Skip to content

ICE: "unsorted CGUs" #113425

Open
Open

Description

@nnethercote

I slightly changed how CGUs are named in #112946 and the fuchsia developers reported an ICE on their Windows CI builds. I created #113402 to give a more informative error message.

@ComputerDruid responded with an updated crash here. I'm now moving this problem into its own issue.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Jul 6, 2023
  2. changed the title [-]unsorted CGUs[/-] [+]ICE: "unsorted CGUs"[/+] on Jul 6, 2023
  3. nnethercote commented on Jul 6, 2023

    @nnethercote
    ContributorAuthor

    [Responding to this comment from the original PR]

    And when I tried switching jemalloc=false on my linux machine, I don't encounter the problem.

    When you have jemalloc=true on linux do you encounter the problem?

    error: internal compiler error: compiler\rustc_monomorphize\src\partitioning.rs:195:9: unsorted CGUs:
                                    - pkg_config.1b83623108ca023c-cgu.0
                                    - pkg_config.1b83623108ca023c-cgu.1
                                    - pkg_config.1b83623108ca023c-cgu.2
                                    - pkg_config.1b83623108ca023c-cgu.3
                                    - pkg_config.1b83623108ca023c-cgu.4
                                    - pkg_config.1b83623108ca023c-cgu.5
                                    - pkg_config.1b83623108ca023c-cgu.6
                                    - pkg_config.1b83623108ca023c-cgu.7
                                    - pkg_config.1b83623108ca023c-cgu.8
                                    - pkg_config.1b83623108ca023c-cgu.9
                                    - pkg_config.1b83623108ca023c-cgu.10
    
    error: internal compiler error: compiler\rustc_monomorphize\src\partitioning.rs:195:9: unsorted CGUs:
                                    - vcpkg.da648edadde02677-cgu.0
                                    - vcpkg.da648edadde02677-cgu.1
                                    - vcpkg.da648edadde02677-cgu.2
                                    - vcpkg.da648edadde02677-cgu.3
                                    - vcpkg.da648edadde02677-cgu.4
                                    - vcpkg.da648edadde02677-cgu.5
                                    - vcpkg.da648edadde02677-cgu.6
                                    - vcpkg.da648edadde02677-cgu.7
                                    - vcpkg.da648edadde02677-cgu.8
                                    - vcpkg.da648edadde02677-cgu.9
                                    - vcpkg.da648edadde02677-cgu.10
                                    - vcpkg.da648edadde02677-cgu.11
                                    - vcpkg.da648edadde02677-cgu.12
                                    - vcpkg.da648edadde02677-cgu.13
                                    - vcpkg.da648edadde02677-cgu.14
                                    - vcpkg.da648edadde02677-cgu.15
    

    Thanks, this is exactly the information I was after. Something weird is going on here -- those numeric suffixes are supposed to be zero-padded, e.g. 00 to 10 for the first examples, and 00 to 15 for the second example. Because then they'd be in name-sorted order. (Without the zero-padding, the one with the 10 suffix is considered lower than the one with the 9 suffix.)

    The code responsible for creating the CGU name is here. It uses let num_digits = codegen_units.len().ilog10() as usize + 1; to compute how many digits the suffix must be, and then creates the suffix with let suffix = format!("{index:0num_digits$}");. Nothing too complicated, except for the use of the magic trailing $ to allow a variable padding amount. And platform independent. The number of CGUs involved in the examples (11 and 16) are completely normal, anything up to 16 is normal, though the code should handle any number. Seems like the kind of code that should not be failing on a single project's CI on a single platform!

    Makes me wonder if there could be a bug on Windows with either ilog10 or the use of 0num_digits$ padding in format!? Though if that was the case every Windows nightly user would be hitting this problem. Hmm.

  4. ComputerDruid commented on Jul 7, 2023

    @ComputerDruid
    Contributor

    When you have jemalloc=true on linux do you encounter the problem?

    No, I just tried that too and neither way can I reproduce the issue on my linux machine

  5. lqd commented on Jul 7, 2023

    @lqd
    Member

    @ComputerDruid your config uses ThinLTO and LLD: I believe you're hitting #109114.

    Removing lto = "thin" will fix it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️O-windows-msvcToolchain: MSVC, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions