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

Large ZST arrays take a looong time to compile #68010

Closed
Nemo157 opened this issue Jan 8, 2020 · 10 comments · Fixed by #78061
Closed

Large ZST arrays take a looong time to compile #68010

Nemo157 opened this issue Jan 8, 2020 · 10 comments · Fixed by #78061
Assignees
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. P-low Low 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

@Nemo157
Copy link
Member

Nemo157 commented Jan 8, 2020

Test case:

fn main() { println!("{}", [(); std::usize::MAX].len()); }

I left it compiling for just over half an hour, and it sat at constant memory usage and 100% of a CPU core for the entire time. Originally tested on rustc 1.41.0-nightly (a605441e0 2019-12-15).

Checking through some different versions, these all take over a minute (I didn't bother sitting around for the full 30 minutes):

  • rustc 1.32.0 (9fda7c223 2019-01-16)
  • rustc 1.33.0 (2aa4c46cf 2019-02-28)
  • rustc 1.35.0 (3c235d560 2019-05-20)
  • rustc 1.40.0 (73528e339 2019-12-16)
  • rustc 1.42.0-nightly (859764425 2020-01-07)

Going back a little further it works and compiles in about a second on:

  • rustc 1.30.0 (da5f414c2 2018-10-24)
  • rustc 1.31.0 (abe02cefd 2018-12-04)

Going back even further it ICEs with capacity overflow on:

  • rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)
  • rustc 1.21.0 (3b72af97e 2017-10-09)

(this may be a duplicate of one of the existing large array compile time issues, but I didn't find one it fit exactly with, especially given it worked on at least two stable releases).

@jonas-schievink jonas-schievink added I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Jan 8, 2020
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Apr 25, 2020
@spastorino spastorino added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 21, 2020
@LeSeulArtichaut LeSeulArtichaut added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label May 21, 2020
@LeSeulArtichaut
Copy link
Contributor

I've tried to compile this with -Zself-profile, but it's been running for two hours and it didn't complete, so I had to cut it off. Maybe someone else can try? I think my computer is getting old :D

So I tried compiling using the compiler for the last commit (installed with rustup-toolchain-install-master):

RUSTC_LOG=rustc cargo +06c9fef822b890054fcefa9a567b57eb6edfe638 build

Here's what I got:

Standard output (if that even matters)

Pre-codegen
Ty interner             total           ty lt ct all
    Adt               :    598 59.4%,  0.0%   3.2%  0.0%  0.0%
    Array             :     27  2.7%,  0.1%   1.9%  0.0%  0.0%
    Slice             :     29  2.9%,  0.1%   1.3%  0.0%  0.0%
    RawPtr            :      6  0.6%,  0.2%   0.0%  0.0%  0.0%
    Ref               :    249 24.7%,  6.9%  17.4%  0.0%  0.0%
    FnDef             :     26  2.6%,  0.3%   1.2%  0.0%  0.0%
    FnPtr             :     10  1.0%,  0.3%   0.1%  0.0%  0.0%
    Placeholder       :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Generator         :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    GeneratorWitness  :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Dynamic           :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Closure           :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Tuple             :      7  0.7%,  0.1%   0.4%  0.0%  0.0%
    Bound             :      3  0.3%,  0.0%   0.0%  0.0%  0.0%
    Param             :     31  3.1%,  0.0%   0.0%  0.0%  0.0%
    Infer             :     20  2.0%,  1.8%   0.0%  0.0%  0.0%
    Projection        :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Opaque            :      0  0.0%,  0.0%   0.0%  0.0%  0.0%
    Foreign           :      1  0.1%,  0.0%   0.0%  0.0%  0.0%
                  total   1007         9.7%  25.4%  0.0%  0.0%
InternalSubsts interner: #495
Region interner: #299
Stability interner: #4
Const Stability interner: #1
Allocation interner: #3
Layout interner: #2

Standard error

   Compiling issue-68010 v0.1.0 (/Users/tous/Documents/Dev/rustc_issues/issue-68010)
[INFO  rustc_metadata::creader] resolving crate `std`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f45f03d2da49250.rlib
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f45f03d2da49250.dylib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f45f03d2da49250.rlib
[INFO  rustc_metadata::locator] reading "libstd-0f45f03d2da49250.rlib" => 437.111µs
[INFO  rustc_metadata::creader] register crate `std` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcore-2e6e530c778a3583.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcore-2e6e530c778a3583.rlib
[INFO  rustc_metadata::locator] reading "libcore-2e6e530c778a3583.rlib" => 700.361µs
[INFO  rustc_metadata::creader] register crate `core` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-0c82ae32e2d88374.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-0c82ae32e2d88374.rlib
[INFO  rustc_metadata::locator] reading "libcompiler_builtins-0c82ae32e2d88374.rlib" => 458.529µs
[INFO  rustc_metadata::creader] register crate `compiler_builtins` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-37c2c6822f6e4416.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-37c2c6822f6e4416.rlib
[INFO  rustc_metadata::locator] reading "librustc_std_workspace_core-37c2c6822f6e4416.rlib" => 74.396µs
[INFO  rustc_metadata::creader] register crate `rustc_std_workspace_core` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate alloc hash: `4c08fcc82d0d94b4` extra filename: `-dba0dd3f64b1b048`
[INFO  rustc_metadata::creader] resolving crate `alloc`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liballoc-dba0dd3f64b1b048.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liballoc-dba0dd3f64b1b048.rlib
[INFO  rustc_metadata::locator] reading "liballoc-dba0dd3f64b1b048.rlib" => 124.559µs
[INFO  rustc_metadata::creader] register crate `alloc` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate libc hash: `50092d883b6ba02a` extra filename: `-98194019dd82bdcf`
[INFO  rustc_metadata::creader] resolving crate `libc`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liblibc-98194019dd82bdcf.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liblibc-98194019dd82bdcf.rlib
[INFO  rustc_metadata::locator] reading "liblibc-98194019dd82bdcf.rlib" => 95.937µs
[INFO  rustc_metadata::creader] register crate `libc` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate unwind hash: `ffb8d575acd55474` extra filename: `-8674563b6131b80f`
[INFO  rustc_metadata::creader] resolving crate `unwind`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libunwind-8674563b6131b80f.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libunwind-8674563b6131b80f.rlib
[INFO  rustc_metadata::locator] reading "libunwind-8674563b6131b80f.rlib" => 54.597µs
[INFO  rustc_metadata::creader] register crate `unwind` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate cfg_if hash: `3b882a78ba209d9e` extra filename: `-4db07e7541300611`
[INFO  rustc_metadata::creader] resolving crate `cfg_if`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-4db07e7541300611.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-4db07e7541300611.rlib
[INFO  rustc_metadata::locator] reading "libcfg_if-4db07e7541300611.rlib" => 51.654µs
[INFO  rustc_metadata::creader] register crate `cfg_if` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate libc hash: `50092d883b6ba02a` extra filename: `-98194019dd82bdcf`
[INFO  rustc_metadata::creader] resolving crate `libc`
[INFO  rustc_metadata::creader] resolving dep crate cfg_if hash: `3b882a78ba209d9e` extra filename: `-4db07e7541300611`
[INFO  rustc_metadata::creader] resolving crate `cfg_if`
[INFO  rustc_metadata::creader] resolving dep crate backtrace hash: `c648361ff198d63b` extra filename: `-b2c92dab277a5d9b`
[INFO  rustc_metadata::creader] resolving crate `backtrace`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-b2c92dab277a5d9b.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-b2c92dab277a5d9b.rlib
[INFO  rustc_metadata::locator] reading "libbacktrace-b2c92dab277a5d9b.rlib" => 56.426µs
[INFO  rustc_metadata::creader] register crate `backtrace` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_demangle hash: `8536a3515849f389` extra filename: `-888de56342cbfebc`
[INFO  rustc_metadata::creader] resolving crate `rustc_demangle`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-888de56342cbfebc.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-888de56342cbfebc.rlib
[INFO  rustc_metadata::locator] reading "librustc_demangle-888de56342cbfebc.rlib" => 61.062µs
[INFO  rustc_metadata::creader] register crate `rustc_demangle` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate cfg_if hash: `3b882a78ba209d9e` extra filename: `-4db07e7541300611`
[INFO  rustc_metadata::creader] resolving crate `cfg_if`
[INFO  rustc_metadata::creader] resolving dep crate backtrace_sys hash: `40a0e352ba38130b` extra filename: `-c0072ed54c7d9db1`
[INFO  rustc_metadata::creader] resolving crate `backtrace_sys`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-c0072ed54c7d9db1.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-c0072ed54c7d9db1.rlib
[INFO  rustc_metadata::locator] reading "libbacktrace_sys-c0072ed54c7d9db1.rlib" => 112.77µs
[INFO  rustc_metadata::creader] register crate `backtrace_sys` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate libc hash: `50092d883b6ba02a` extra filename: `-98194019dd82bdcf`
[INFO  rustc_metadata::creader] resolving crate `libc`
[INFO  rustc_metadata::creader] resolving dep crate libc hash: `50092d883b6ba02a` extra filename: `-98194019dd82bdcf`
[INFO  rustc_metadata::creader] resolving crate `libc`
[INFO  rustc_metadata::creader] resolving dep crate rustc_demangle hash: `8536a3515849f389` extra filename: `-888de56342cbfebc`
[INFO  rustc_metadata::creader] resolving crate `rustc_demangle`
[INFO  rustc_metadata::creader] resolving dep crate backtrace_sys hash: `40a0e352ba38130b` extra filename: `-c0072ed54c7d9db1`
[INFO  rustc_metadata::creader] resolving crate `backtrace_sys`
[INFO  rustc_metadata::creader] resolving dep crate hashbrown hash: `41ec51d5926b807b` extra filename: `-c821a16ee9af438e`
[INFO  rustc_metadata::creader] resolving crate `hashbrown`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-c821a16ee9af438e.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-c821a16ee9af438e.rlib
[INFO  rustc_metadata::locator] reading "libhashbrown-c821a16ee9af438e.rlib" => 112.12µs
[INFO  rustc_metadata::creader] register crate `hashbrown` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_alloc hash: `965ce24b6edc874d` extra filename: `-0bdca3ffed29a4e6`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_alloc`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-0bdca3ffed29a4e6.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-0bdca3ffed29a4e6.rlib
[INFO  rustc_metadata::locator] reading "librustc_std_workspace_alloc-0bdca3ffed29a4e6.rlib" => 68.962µs
[INFO  rustc_metadata::creader] register crate `rustc_std_workspace_alloc` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate alloc hash: `4c08fcc82d0d94b4` extra filename: `-dba0dd3f64b1b048`
[INFO  rustc_metadata::creader] resolving crate `alloc`
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate alloc hash: `4c08fcc82d0d94b4` extra filename: `-dba0dd3f64b1b048`
[INFO  rustc_metadata::creader] resolving crate `alloc`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_alloc hash: `965ce24b6edc874d` extra filename: `-0bdca3ffed29a4e6`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_alloc`
[INFO  rustc_metadata::creader] resolving dep crate panic_unwind hash: `548e742a1a7c3b43` extra filename: `-a3a92c27c63062f8`
[INFO  rustc_metadata::creader] resolving crate `panic_unwind`
[INFO  rustc_metadata::creader] falling back to a load
[INFO  rustc_metadata::locator] lib candidate: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-a3a92c27c63062f8.rlib
[INFO  rustc_metadata::locator] rlib reading metadata from: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-a3a92c27c63062f8.rlib
[INFO  rustc_metadata::locator] reading "libpanic_unwind-a3a92c27c63062f8.rlib" => 74.341µs
[INFO  rustc_metadata::creader] register crate `panic_unwind` (private_dep = false)
[INFO  rustc_metadata::creader] resolving dep crate core hash: `307eec53ae469652` extra filename: `-2e6e530c778a3583`
[INFO  rustc_metadata::creader] resolving crate `core`
[INFO  rustc_metadata::creader] resolving dep crate compiler_builtins hash: `9ef2d0d352c9bad3` extra filename: `-0c82ae32e2d88374`
[INFO  rustc_metadata::creader] resolving crate `compiler_builtins`
[INFO  rustc_metadata::creader] resolving dep crate rustc_std_workspace_core hash: `2de978cfb410d5f3` extra filename: `-37c2c6822f6e4416`
[INFO  rustc_metadata::creader] resolving crate `rustc_std_workspace_core`
[INFO  rustc_metadata::creader] resolving dep crate alloc hash: `4c08fcc82d0d94b4` extra filename: `-dba0dd3f64b1b048`
[INFO  rustc_metadata::creader] resolving crate `alloc`
[INFO  rustc_metadata::creader] resolving dep crate cfg_if hash: `3b882a78ba209d9e` extra filename: `-4db07e7541300611`
[INFO  rustc_metadata::creader] resolving crate `cfg_if`
[INFO  rustc_metadata::creader] resolving dep crate libc hash: `50092d883b6ba02a` extra filename: `-98194019dd82bdcf`
[INFO  rustc_metadata::creader] resolving crate `libc`
[INFO  rustc_metadata::creader] resolving dep crate unwind hash: `ffb8d575acd55474` extra filename: `-8674563b6131b80f`
[INFO  rustc_metadata::creader] resolving crate `unwind`
[INFO  rustc_metadata::creader] resolving crate `std`
[INFO  rustc_metadata::creader] injecting a dep from 1 to 14
[INFO  rustc_metadata::creader] panic runtime not found -- loading panic_unwind
[INFO  rustc_metadata::creader] resolving crate `panic_unwind`
[INFO  rustc_metadata::creader] injecting a dep from 1 to 14
[INFO  rustc_metadata::creader] resolved crates:
[INFO  rustc_metadata::creader]   name: std
[INFO  rustc_metadata::creader]   cnum: 1
[INFO  rustc_metadata::creader]   hash: 036b1f43ca965b65
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]   dylib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f45f03d2da49250.dylib
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libstd-0f45f03d2da49250.rlib
[INFO  rustc_metadata::creader]   name: core
[INFO  rustc_metadata::creader]   cnum: 2
[INFO  rustc_metadata::creader]   hash: 307eec53ae469652
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcore-2e6e530c778a3583.rlib
[INFO  rustc_metadata::creader]   name: compiler_builtins
[INFO  rustc_metadata::creader]   cnum: 3
[INFO  rustc_metadata::creader]   hash: 9ef2d0d352c9bad3
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-0c82ae32e2d88374.rlib
[INFO  rustc_metadata::creader]   name: rustc_std_workspace_core
[INFO  rustc_metadata::creader]   cnum: 4
[INFO  rustc_metadata::creader]   hash: 2de978cfb410d5f3
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-37c2c6822f6e4416.rlib
[INFO  rustc_metadata::creader]   name: alloc
[INFO  rustc_metadata::creader]   cnum: 5
[INFO  rustc_metadata::creader]   hash: 4c08fcc82d0d94b4
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liballoc-dba0dd3f64b1b048.rlib
[INFO  rustc_metadata::creader]   name: libc
[INFO  rustc_metadata::creader]   cnum: 6
[INFO  rustc_metadata::creader]   hash: 50092d883b6ba02a
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/liblibc-98194019dd82bdcf.rlib
[INFO  rustc_metadata::creader]   name: unwind
[INFO  rustc_metadata::creader]   cnum: 7
[INFO  rustc_metadata::creader]   hash: ffb8d575acd55474
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libunwind-8674563b6131b80f.rlib
[INFO  rustc_metadata::creader]   name: cfg_if
[INFO  rustc_metadata::creader]   cnum: 8
[INFO  rustc_metadata::creader]   hash: 3b882a78ba209d9e
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-4db07e7541300611.rlib
[INFO  rustc_metadata::creader]   name: backtrace
[INFO  rustc_metadata::creader]   cnum: 9
[INFO  rustc_metadata::creader]   hash: c648361ff198d63b
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-b2c92dab277a5d9b.rlib
[INFO  rustc_metadata::creader]   name: rustc_demangle
[INFO  rustc_metadata::creader]   cnum: 10
[INFO  rustc_metadata::creader]   hash: 8536a3515849f389
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-888de56342cbfebc.rlib
[INFO  rustc_metadata::creader]   name: backtrace_sys
[INFO  rustc_metadata::creader]   cnum: 11
[INFO  rustc_metadata::creader]   hash: 40a0e352ba38130b
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-c0072ed54c7d9db1.rlib
[INFO  rustc_metadata::creader]   name: hashbrown
[INFO  rustc_metadata::creader]   cnum: 12
[INFO  rustc_metadata::creader]   hash: 41ec51d5926b807b
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-c821a16ee9af438e.rlib
[INFO  rustc_metadata::creader]   name: rustc_std_workspace_alloc
[INFO  rustc_metadata::creader]   cnum: 13
[INFO  rustc_metadata::creader]   hash: 965ce24b6edc874d
[INFO  rustc_metadata::creader]   reqd: Explicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-0bdca3ffed29a4e6.rlib
[INFO  rustc_metadata::creader]   name: panic_unwind
[INFO  rustc_metadata::creader]   cnum: 14
[INFO  rustc_metadata::creader]   hash: 548e742a1a7c3b43
[INFO  rustc_metadata::creader]   reqd: Implicit
[INFO  rustc_metadata::creader]    rlib: /Users/tous/.rustup/toolchains/06c9fef822b890054fcefa9a567b57eb6edfe638/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-a3a92c27c63062f8.rlib
[INFO  rustc_interface::passes] 0 parse sess buffered_lints
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) main::{{constant}}#0
[INFO  rustc_mir::interpret::step] _0 = const std::usize::MAX
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) std::usize::MAX
[INFO  rustc_mir::interpret::step] _0 = const core::num::<impl usize>::MAX
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) core::num::<impl usize>::MAX
[INFO  rustc_mir::interpret::step] _0 = const std::usize::MAX
[INFO  rustc_mir::interpret::step] return
[INFO  rustc_mir::interpret::eval_context] LEAVING(0) core::num::<impl usize>::MAX (unwinding = false)
[INFO  rustc_mir::interpret::step] return
[INFO  rustc_mir::interpret::eval_context] LEAVING(0) std::usize::MAX (unwinding = false)
[INFO  rustc_mir::interpret::step] return
[INFO  rustc_mir::interpret::eval_context] LEAVING(0) main::{{constant}}#0 (unwinding = false)
[INFO  rustc_traits::dropck_outlives] 0 kinds, 0 overflows, 0 ty_stack
[INFO  rustc_traits::dropck_outlives] 0 kinds, 0 overflows, 0 ty_stack
[INFO  rustc_traits::dropck_outlives] 0 kinds, 0 overflows, 0 ty_stack
[INFO  rustc_traits::dropck_outlives] 0 kinds, 0 overflows, 0 ty_stack
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) main
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) main
[INFO  rustc_mir::interpret::step] _3 = const ""
[INFO  rustc_mir::interpret::step] _2 = _3
[INFO  rustc_mir::interpret::step] _5 = const "\n"
[INFO  rustc_mir::interpret::step] _4 = _5
[INFO  rustc_mir::interpret::step] _1 = [move _2, move _4]
[INFO  rustc_mir::interpret::step] _0 = &_1
[INFO  rustc_mir::interpret::step] return
[INFO  rustc_mir::interpret::eval_context] LEAVING(0) main (unwinding = false)
[INFO  rustc_mir::interpret::eval_context] ENTERING(0) main
[INFO  rustc_mir::interpret::step] _1 = [move _2; std::usize::MAX]
[INFO  rustc_mir::interpret::step] _0 = &_1
[INFO  rustc_mir::interpret::step] return
[INFO  rustc_mir::interpret::eval_context] LEAVING(0) main (unwinding = false)

This last line:

[INFO  rustc_mir::interpret::eval_context] LEAVING(0) main (unwinding = false)

Is emitted in here:

pub(super) fn pop_stack_frame(&mut self, unwinding: bool) -> InterpResult<'tcx> {
info!(
"LEAVING({}) {} (unwinding = {})",
self.frame_idx(),
self.frame().instance,
unwinding
);
// Sanity check `unwinding`.
assert_eq!(
unwinding,
match self.frame().loc {
None => true,
Some(loc) => self.body().basic_blocks()[loc.block].is_cleanup,
}
);
::log_settings::settings().indentation -= 1;
let frame =
self.stack_mut().pop().expect("tried to pop a stack frame, but there were none");
if !unwinding {
// Copy the return value to the caller's stack frame.
if let Some(return_place) = frame.return_place {
let op = self.access_local(&frame, mir::RETURN_PLACE, None)?;
self.copy_op_transmute(op, return_place)?;
self.dump_place(*return_place);
} else {
throw_ub!(Unreachable);
}
}
// Now where do we jump next?
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
// In that case, we return early. We also avoid validation in that case,
// because this is CTFE and the final value will be thoroughly validated anyway.
let (cleanup, next_block) = match frame.return_to_block {
StackPopCleanup::Goto { ret, unwind } => {
(true, Some(if unwinding { unwind } else { ret }))
}
StackPopCleanup::None { cleanup, .. } => (cleanup, None),
};
if !cleanup {
assert!(self.stack().is_empty(), "only the topmost frame should ever be leaked");
assert!(next_block.is_none(), "tried to skip cleanup when we have a next block!");
assert!(!unwinding, "tried to skip cleanup during unwinding");
// Leak the locals, skip validation, skip machine hook.
return Ok(());
}
// Cleanup: deallocate all locals that are backed by an allocation.
for local in &frame.locals {
self.deallocate_local(local.value)?;
}
if M::after_stack_pop(self, frame, unwinding)? == StackPopJump::NoJump {
// The hook already did everything.
// We want to skip the `info!` below, hence early return.
return Ok(());
}
// Normal return, figure out where to jump.
if unwinding {
// Follow the unwind edge.
let unwind = next_block.expect("Encountered StackPopCleanup::None when unwinding!");
self.unwind_to_block(unwind);
} else {
// Follow the normal return edge.
if let Some(ret) = next_block {
self.return_to_block(ret)?;
}
}
if !self.stack().is_empty() {
info!(
"CONTINUING({}) {} (unwinding = {})",
self.frame_idx(),
self.frame().instance,
unwinding
);
}
Ok(())
}

So I believe this is a const eval bug?
cc @RalfJung do you have any idea what may be happening?

@RalfJung
Copy link
Member

Hm, not off the top of my head. Cc @rust-lang/wg-const-eval

I take it it keeps going after that last line without outputting anything any more? Then that's just the last thing it completed, which might or might not have anything to do with the next thing it is doing. Could you use gdb to capture a backtrace of what code it is running then? (Let me know if you need help with that.)

@LeSeulArtichaut
Copy link
Contributor

Here is the LLDB output for the bt all command with latest nightly (0aa6751).

@RalfJung
Copy link
Member

Okay so this is interning walking every single field of that array... and taking forever to do that, obviously.

@LeSeulArtichaut
Copy link
Contributor

Letting it run a bit longer gave me an additional frame:

frame #0: 0x0000000102f3bcb6 librustc_driver-e74b82e42afdd3af.dylib`rustc_mir::interpret::visitor::ValueVisitor::walk_aggregate::he89096da12c8cd69 + 614

@LeSeulArtichaut
Copy link
Contributor

@Nemo157 How did you originally find this? Did it impact a real code you had?

@LeSeulArtichaut LeSeulArtichaut added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 21, 2020
@LeSeulArtichaut
Copy link
Contributor

@Nemo157
Copy link
Member Author

Nemo157 commented May 22, 2020

@LeSeulArtichaut the context was around here on discord, I was just trying to find out whether you could have a ZST array with length > isize::MAX, so no, not real code.

@LeSeulArtichaut
Copy link
Contributor

Alright, it is fine being P-low then 👍

@oli-obk
Copy link
Contributor

oli-obk commented May 26, 2020

For arrays and slices we could make interning check the relocation map for relocations within the array, compute the indices which have relocations and only look at those indices.

This way we don't have to walk all elements, but only those that interning cares about. Not sure what validation will do after interning is finished, maybe that'll also run forever? I thought we had some optimizations in there.

Oh yea, and interning can skip any zst type in general.

@wesleywiser wesleywiser self-assigned this Oct 16, 2020
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Oct 20, 2020
…, r=oli-obk

Optimize const value interning for ZST types

Interning can skip any inhabited ZST type in general.

Fixes rust-lang#68010

r? @oli-obk
@bors bors closed this as completed in 3fea201 Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times. P-low Low 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

Successfully merging a pull request may close this issue.

7 participants