Run cargo check on this code: cosven/tikv@861b3e5, cargo check hangs.
When I change the code to cosven/tikv@e546489, the problem goes away and the check passes.
The code has the following diff :)

You can also reproduce this problem with following steps
git clone https://github.com/cosven/tikv.git
cd tikv/
git checkout rustc-deadloop-repro
# This commit can help repro the bug.
# And rustc behaves well on the latest commit.
git checkout HEAD^
cargo check --workspace --all-targets
I expected to see: cargo check should report a error, because the function call lacks a parameter.
Instead, this happened: cargo check hangs. The CPU usage of the rustc process goes 100%.
Meta
rustc --version --verbose:
rustc 1.64.0-nightly (0f4bcadb4 2022-07-30)
binary: rustc
commit-hash: 0f4bcadb46006bc484dad85616b484f93879ca4e
commit-date: 2022-07-30
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6
The pstack result is as follows, I think (not very sure) the problem may be related to this piece of code
|
loop { |
|
stack.push(j); |
|
// Look for params this one could slot into |
|
let compat: Vec<_> = |
|
mat[j] |
|
.iter() |
|
.enumerate() |
|
.filter_map(|(i, c)| { |
|
if matches!(c, Compatibility::Compatible) { Some(i) } else { None } |
|
}) |
|
.collect(); |
|
if compat.len() != 1 { |
|
// this could go into multiple slots, don't bother exploring both |
|
is_cycle = false; |
|
break; |
|
} |
|
j = compat[0]; |
|
if stack.contains(&j) { |
|
last = j; |
|
break; |
|
} |
|
} |
Backtrace
~ > pstack `pgrep rustc`
Thread 2 (Thread 0x7f562277f700 (LWP 8210)):
#0 0x00007f562c2e001e in _RNvXNtNtCsjGak25GVoR2_5alloc3vec14spec_from_iterINtB4_3VecjEINtB2_12SpecFromIterjINtNtNtNtCs4Bj0LzfGV1R_4core4iter8adapters10filter_map9FilterMapINtNtB1m_9enumerate9EnumerateINtNtNtB1q_5slice4iter4IterNtNtNtNtCsWyxMbfqFoB_12rustc_typeck5check7fn_ctxt10arg_matrix13CompatibilityEENCNvMs_B3f_NtB3f_9ArgMatrix10find_issue0EE9from_iterB3l_ () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#1 0x00007f562c20d532 in _RNvMs_NtNtNtCsWyxMbfqFoB_12rustc_typeck5check7fn_ctxt10arg_matrixNtB4_9ArgMatrix11find_errors () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#2 0x00007f562c1bf1ca in _RNvMNtNtNtCsWyxMbfqFoB_12rustc_typeck5check7fn_ctxt6checksNtB4_6FnCtxt17report_arg_errors () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#3 0x00007f562a8f2e96 in _RNvMNtNtNtCsWyxMbfqFoB_12rustc_typeck5check7fn_ctxt6checksNtB4_6FnCtxt20check_argument_types () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#4 0x00007f562a8f6d3f in _RNvMNtNtCsWyxMbfqFoB_12rustc_typeck5check4exprNtNtB4_7fn_ctxt6FnCtxt36check_expr_with_expectation_and_args.llvm.9954290265029759861 () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#5 0x00007f562a8f593c in _RNvMNtNtCsWyxMbfqFoB_12rustc_typeck5check4exprNtNtB4_7fn_ctxt6FnCtxt36check_expr_with_expectation_and_args.llvm.9954290265029759861 () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
#6 0x00007f562a90af3f in _RNvMNtNtNtCsWyxMbfqFoB_12rustc_typeck5check7fn_ctxt6checksNtB4_6FnCtxt25check_block_with_expected () from /root/.rustup/toolchains/nightly-2022-07-31-x86_64-unknown-linux-gnu/lib/librustc_driver-c25a516c3d8f3eb8.so
Run cargo check on this code: cosven/tikv@861b3e5, cargo check hangs.
When I change the code to cosven/tikv@e546489, the problem goes away and the check passes.
The code has the following diff :)

You can also reproduce this problem with following steps
I expected to see: cargo check should report a error, because the function call lacks a parameter.
Instead, this happened: cargo check hangs. The CPU usage of the rustc process goes 100%.
Meta
rustc --version --verbose:The pstack result is as follows, I think (not very sure) the problem may be related to this piece of code
rust/compiler/rustc_typeck/src/check/fn_ctxt/arg_matrix.rs
Lines 224 to 245 in 46c59bb
Backtrace