rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.57k stars 12.74k forks source link

ICE - panic while trying to force a dep node #117903

Closed Cryptex-github closed 1 year ago

Cryptex-github commented 1 year ago

Code

https://github.com/AdaptChat/harmony/tree/ice - repo where ICE happened.

I have attempted to create a minimal verifiable example, however, given this ICE involves async which makes it a lot harder to reproduce an example, I can't provide a minimal verifiable example at this moment. However, I've done some investigations.

Likely originated from the tokio::main macro.

The error is related to:

match socket::accept(stream).await {

}

https://github.com/AdaptChat/harmony/blob/4782a856468dff82bd20a3fe2675306abd4cb4e3/src/main.rs#L27-L29

When the branches are left empty, the ICE is triggered. However, it disappears when the branches are filled in, e.g.:

match socket::accept(stream).await {
    Ok(_) => {},
    Err(_) => {},
}

It's extremely hard to reproduce and even one slight modification somewhere will cause the ICE to disappear. Even then, the ICE isn't triggered single time, is very random.

Meta

rustc --version --verbose:

rustc 1.75.0-nightly (edf0b1db0 2023-11-10)
binary: rustc
commit-hash: edf0b1db0a7f29d71ee82cfc53bdc170fe74e501
commit-date: 2023-11-10
host: x86_64-pc-windows-msvc
release: 1.75.0-nightly
LLVM version: 17.0.4

I have the new parallel front-end on:

-Z threads=4

Error output

error: internal compiler error: compiler\rustc_mir_transform\src\coroutine.rs:1463:14: unexpected coroutine type Pin<&mut {async block@src\main.rs:9:1: 9:15}>
 --> src\main.rs:9:1
  |
9 | #[tokio::main]
  | ^^^^^^^^^^^^^^
  |
  = note: this error: internal compiler error originates in the attribute macro `tokio::main` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at /rustc/edf0b1db0a7f29d71ee82cfc53bdc170fe74e501\compiler\rustc_errors\src\lib.rs:1000:33:
Box<dyn Any>
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `C:\Users\...\OneDrive\Desktop\repos\harmony\rustc-ice-2023-11-14T07_36_58-8752.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -Z threads=4 -C target-cpu=native

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_coroutine_witnesses] coroutine witness types for `main::{closure#0}`
#1 [dropck_outlives] computing dropck types for `{async block@src\main.rs:9:1: 9:15}`
#2 [mir_borrowck] borrow-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 needs_drop_raw(a728502a26f3420b-f2514fc61b0d6e4e)
#1 dropck_outlives(61dd7136bcfdfb0b-d4f98cc665d05364)
end of try_mark_green dep node stack
For more information about this error, try `rustc --explain E0004`.
error: could not compile `harmony` (bin "harmony") due to previous error
Backtrace

``` thread 'rustc' panicked at /rustc/edf0b1db0a7f29d71ee82cfc53bdc170fe74e501\compiler\rustc_errors\src\lib.rs:1000:33: Box stack backtrace: 0: 0x7ffd5d34dc8f - std::backtrace::Backtrace::force_capture::h2dc498c6c0410861 1: 0x7ffd5d34dbf4 - std::backtrace::Backtrace::force_capture::h2dc498c6c0410861 2: 0x7ffd32978a89 - ::write_fmt 3: 0x7ffd5d366793 - std::panicking::rust_panic_with_hook::h94b5f7224cb3ff18 4: 0x7ffd32ec5738 - rustc_mir_transform[795bb961ec71e5b3]::dump_mir::emit_mir 5: 0x7ffd32ec0139 - rustc_mir_transform[795bb961ec71e5b3]::dump_mir::emit_mir 6: 0x7ffd32f0bc49 - ::array_subpath 7: 0x7ffd32e31bb6 - rustc_mir_transform[795bb961ec71e5b3]::coroutine::mir_coroutine_witnesses 8: 0x7ffd32e31918 - rustc_mir_transform[795bb961ec71e5b3]::coroutine::mir_coroutine_witnesses 9: 0x7ffd32f17137 - ::array_subpath 10: 0x7ffd32f1716d - ::array_subpath 11: 0x7ffd32f12baf - ::array_subpath 12: 0x7ffd32f12b56 - ::array_subpath 13: 0x7ffd32e2f6eb - rustc_mir_transform[795bb961ec71e5b3]::coroutine::mir_coroutine_witnesses 14: 0x7ffd33487de2 - ::depth_limit_error 15: 0x7ffd334d3903 - ::depth_limit_error 16: 0x7ffd322ddde7 - ::load_side_effects 17: 0x7ffd314db9fb - rustc_query_impl[35472db2040f6fb3]::profiling_support::alloc_self_profile_query_strings 18: 0x7ffd3347429f - ::spec_to_self_profile_string 19: 0x7ffd3220f56b - ::load_side_effects 20: 0x7ffd3220f503 - ::load_side_effects 21: 0x7ffd3228b0be - ::load_side_effects 22: 0x7ffd314aaed2 - rustc_query_impl[35472db2040f6fb3]::profiling_support::alloc_self_profile_query_strings 23: 0x7ffd3239ff88 - ::perform_query 24: 0x7ffd321074ad - ::visit_body 25: 0x7ffd320a2199 - ::ignore_borrow 26: 0x7ffd3212d05f - ::bottom_value 27: 0x7ffd320a772f - ::push_outlives 28: 0x7ffd321509e1 - ::bottom_value 29: 0x7ffd320617b6 - ::consume_operand 30: 0x7ffd32053e9d - rustc_borrowck[4a426328d0b3d822]::mir_borrowck 31: 0x7ffd321f6c7f - ::load_side_effects 32: 0x7ffd3224ecef - ::load_side_effects 33: 0x7ffd3231b91e - ::load_side_effects 34: 0x7ffd321ee5a9 - rustc_query_impl[35472db2040f6fb3]::query_callbacks 35: 0x7ffd32aa4922 - rustc_interface[89de7afe51a89d52]::util::rustc_path 36: 0x7ffd32aa0d16 - rustc_interface[89de7afe51a89d52]::util::rustc_path 37: 0x7ffd32a9880f - rustc_interface[89de7afe51a89d52]::util::rustc_path 38: 0x7ffd32aa4665 - rustc_interface[89de7afe51a89d52]::util::rustc_path 39: 0x7ffd32a5805f - rustc_interface[89de7afe51a89d52]::util::rustc_path 40: 0x7ffd32a2ce3f - rustc_interface[89de7afe51a89d52]::callbacks::dep_node_debug 41: 0x7ffd32aa4665 - rustc_interface[89de7afe51a89d52]::util::rustc_path 42: 0x7ffd32a5805f - rustc_interface[89de7afe51a89d52]::util::rustc_path 43: 0x7ffd32a2ce3f - rustc_interface[89de7afe51a89d52]::callbacks::dep_node_debug 44: 0x7ffd32aa7d7a - rustc_interface[89de7afe51a89d52]::util::rustc_path 45: 0x7ffd32a581af - rustc_interface[89de7afe51a89d52]::util::rustc_path 46: 0x7ffd32a2ce3f - rustc_interface[89de7afe51a89d52]::callbacks::dep_node_debug 47: 0x7ffd32aad6c4 - rustc_interface[89de7afe51a89d52]::util::rustc_path 48: 0x7ffd34084226 - ::wait_until_cold 49: 0x7ffd34082640 - ::run 50: 0x7ffd32939062 - ::fmt 51: 0x7ffd32959f7a - ::fmt 52: 0x7ffd3297879d - ::fmt 53: 0x7ffd3291d4d9 - rustc_driver_impl[6c8bd495863d11da]::init_env_logger 54: 0x7ffd32953d0b - ::fmt 55: 0x7ffd3291d6a7 - rustc_driver_impl[6c8bd495863d11da]::init_env_logger 56: 0x7ffd5d3789fc - std::sys::windows::thread::Thread::new::h67dfe1634550644f 57: 0x7ffdb60e7614 - BaseThreadInitThunk 58: 0x7ffdb6da26f1 - RtlUserThreadStart rustc version: 1.75.0-nightly (edf0b1db0 2023-11-10) platform: x86_64-pc-windows-msvc query stack during panic: #0 [mir_coroutine_witnesses] coroutine witness types for `main::{closure#0}` #1 [dropck_outlives] computing dropck types for `{async block@src\main.rs:9:1: 9:15}` #2 [mir_borrowck] borrow-checking `main` #3 [analysis] running analysis passes on this crate end of query stack ```

lqd commented 1 year ago

Looks like a duplicate of #117670 which should be fixed by #117686

jruderman commented 1 year ago

Cryptex, can you check whether your ICE is fixed in a newer nightly, now that #117686 is in?

Cryptex-github commented 1 year ago

Cryptex, can you check whether your ICE is fixed in a newer nightly, now that #117686 is in?

This ICE seems to be gone as of rustc 1.76.0-nightly (6b771f6b5 2023-11-15), or at least I can't reproduce it anymore. Feel free to close this if you'd like, thanks.