Skip to content
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

ICE: "unsorted CGUs" #113425

Open
nnethercote opened this issue Jul 6, 2023 · 3 comments
Open

ICE: "unsorted CGUs" #113425

nnethercote opened this issue Jul 6, 2023 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-windows-msvc Toolchain: MSVC, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nnethercote
Copy link
Contributor

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.

@nnethercote nnethercote added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jul 6, 2023
@nnethercote nnethercote changed the title unsorted CGUs ICE: "unsorted CGUs" Jul 6, 2023
@nnethercote
Copy link
Contributor Author

nnethercote commented Jul 6, 2023

[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.

@ComputerDruid
Copy link
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

@lqd
Copy link
Member

lqd commented Jul 7, 2023

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

Removing lto = "thin" will fix it.

@jyn514 jyn514 added the O-windows-msvc Toolchain: MSVC, Operating system: Windows label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-windows-msvc Toolchain: MSVC, Operating system: Windows 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