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 when type not specificed for static variable (Embassy) #127211

Closed
perowle opened this issue Jul 1, 2024 · 5 comments
Closed

ICE when type not specificed for static variable (Embassy) #127211

perowle opened this issue Jul 1, 2024 · 5 comments
Labels
C-bug Category: This is a bug. 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.

Comments

@perowle
Copy link

perowle commented Jul 1, 2024

Code

#![no_std]
#![no_main]
#![deny(missing_docs, unsafe_code)]

use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::pubsub::{PubSubChannel };
use {defmt_rtt as _, panic_probe as _};
use embassy_executor::Spawner;

static temperature_channel = PubSubChannel::<NoopRawMutex, f32, 1, 2, 2>::new();

#[embassy_executor::main]
async fn main(spawner: Spawner) {
let p = embassy_stm32::init(Default::default());

let temp0 = temperature_channel.dyn_publisher().unwrap();

}

Meta

rustc --version --verbose:

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-pc-windows-msvc
release: 1.79.0
LLVM version: 18.1.7

Error output

cargo build
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on build directory
   Compiling nucleo-f411re v0.1.0 (C:\git\rust\ec\examples\ECProto - Copy\nucleo-f411re)
error: missing type for `static` item
  --> nucleo-f411re\src/main.rs:13:27
   |
13 | static temperature_channel = PubSubChannel::<NoopRawMutex, f32, 1, 2, 2>::new();
   |                           ^ help: provide a type for the static variable: `: PubSubChannel<NoopRawMutex, f32, 1, 2, 2>`

thread 'rustc' panicked at compiler\rustc_const_eval\src\interpret\validity.rs:733:21:
assertion `left == right` failed
  left: Mut
 right: Not
stack backtrace:
   0:     0x7ffbc2eb3c48 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffbc2eb3c48 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffbc2eb3c48 - std::sys_common::backtrace::_print_fmt
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\sys_common\backtrace.rs:68
   3:     0x7ffbc2eb3c48 - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\sys_common\backtrace.rs:44
   4:     0x7ffbc2ee4f09 - core::fmt::rt::Argument::fmt
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\fmt\rt.rs:165
   5:     0x7ffbc2ee4f09 - core::fmt::write
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\fmt\mod.rs:1157
   6:     0x7ffbc2eaa3e1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\io\mod.rs:1832
   7:     0x7ffbc2eb3a26 - std::sys_common::backtrace::print
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\sys_common\backtrace.rs:34
   8:     0x7ffbc2eb6b88 - std::panicking::default_hook::closure$1
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:271
   9:     0x7ffbc2eb67f7 - std::panicking::default_hook
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:298
  10:     0x7ffba29bfdfe - __longjmp_internal
  11:     0x7ffbc2eb71b7 - alloc::boxed::impl$50::call
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\alloc\src\boxed.rs:2036
  12:     0x7ffbc2eb71b7 - std::panicking::rust_panic_with_hook
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:799
  13:     0x7ffbc2eb7047 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:664
  14:     0x7ffbc2eb45bf - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\sys_common\backtrace.rs:171
  15:     0x7ffbc2eb6cf8 - std::panicking::begin_panic_handler
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\panicking.rs:652
  16:     0x7ffbc2f0d7d4 - core::panicking::panic_fmt
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\panicking.rs:72
  17:     0x7ffbc2f0dc21 - core::panicking::assert_failed_inner
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\core\src\panicking.rs:409
  18:     0x7ffba343c607 - <unicode_script[df3ac769750e1c82]::ScriptIterator as core[bd51e8c031ece540]::iter::traits::iterator::Iterator>::next
  19:     0x7ffba2205003 - <rustc_const_eval[254959616a52d48e]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  20:     0x7ffba220556d - <rustc_const_eval[254959616a52d48e]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  21:     0x7ffba2205470 - <rustc_const_eval[254959616a52d48e]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  22:     0x7ffba2205470 - <rustc_const_eval[254959616a52d48e]::interpret::eval_context::InterpCx<_>>::storage_live_dyn::is_very_trivially_sized
  23:     0x7ffba137f4df - rustc_const_eval[254959616a52d48e]::interpret::eval_context::mir_assign_valid_types
  24:     0x7ffba2274da5 - rustc_const_eval[254959616a52d48e]::util::compare_types::relate_types
  25:     0x7ffba1385a40 - rustc_const_eval[254959616a52d48e]::const_eval::eval_queries::eval_static_initializer_provider
  26:     0x7ffba12e15c8 - <dyn std[97e236bc5ac76467]::io::Write as nu_ansi_term[46f323ea840c8206]::write::AnyWrite>::write_str
  27:     0x7ffba12ca18d - <dyn std[97e236bc5ac76467]::io::Write as nu_ansi_term[46f323ea840c8206]::write::AnyWrite>::write_str
  28:     0x7ffba1facadb - rustc_traits[df3a8b33046bddd2]::type_op::type_op_prove_predicate
  29:     0x7ffba12f7048 - rustc_query_impl[46f2cb59a7e58a2f]::query_system
  30:     0x7ffba196a9d3 - rustc_hir_analysis[d196ce244286923b]::check_crate
  31:     0x7ffba16e52c6 - <rustc_interface[5039fedd6fed528e]::passes::LintStoreExpandImpl as rustc_expand[8a362ccb6e11b5d0]::base::LintStoreExpand>::pre_expansion_lint
  32:     0x7ffba12e1f5a - <dyn std[97e236bc5ac76467]::io::Write as nu_ansi_term[46f323ea840c8206]::write::AnyWrite>::write_str
  33:     0x7ffba1257af1 - rustc_traits[df3a8b33046bddd2]::type_op::type_op_normalize_clause
  34:     0x7ffba12eaa07 - rustc_query_impl[46f2cb59a7e58a2f]::query_system
  35:     0x7ffb9e7147c2 - llvm::function_ref<void __cdecl(llvm::Value const * __ptr64)>::callback_fn<`llvm::Value::stripInBoundsOffsets'::`1'::<lambda_1_1> >
  36:     0x7ffb9e711a96 - llvm::function_ref<void __cdecl(llvm::Value const * __ptr64)>::callback_fn<`llvm::Value::stripInBoundsOffsets'::`1'::<lambda_1_1> >
  37:     0x7ffb9e7195f9 - llvm::function_ref<void __cdecl(llvm::Value const * __ptr64)>::callback_fn<`llvm::Value::stripInBoundsOffsets'::`1'::<lambda_1_1> >
  38:     0x7ffbc2ec822d - alloc::boxed::impl$48::call_once
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\alloc\src\boxed.rs:2022
  39:     0x7ffbc2ec822d - alloc::boxed::impl$48::call_once
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\alloc\src\boxed.rs:2022
  40:     0x7ffbc2ec822d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library\std\src\sys\pal\windows\thread.rs:52
  41:     0x7ffc58e9257d - BaseThreadInitThunk
  42:     0x7ffc5964af28 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.79.0 (129f3b996 2024-06-10) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 -C debug-assertions=on -C link-arg=--nmagic -C link-arg=-Tlink.x -C link-arg=-Tdefmt.x

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

query stack during panic:
#0 [eval_static_initializer] evaluating initializer of static `temperature_channel`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `nucleo-f411re` (bin "nucleo-f411re") due to 1 previous error
Backtrace

Included above

@perowle perowle added C-bug Category: This is a bug. 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. labels Jul 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 1, 2024
@pacak
Copy link
Contributor

pacak commented Jul 1, 2024

Can you share a bit more info about building the project? Cargo.toml file, environment variables you need to set, etc?

@perowle
Copy link
Author

perowle commented Jul 1, 2024

Sorry, yeah here's the Cargo.toml contents and instructions for building at the bottom.

Cargo.toml contents:

[package]
resolver = "2"
name = "nucleo-f411re"
categories = [ "embedded", "no-std" ]
version = "0.1.0"
edition = "2021"
keywords = [ "embedded", "no-std", "embedded-hal" ]
license = "MIT"
rust-version = "1.76"

[dependencies]
embassy-stm32 = { git = "https://github.com/embassy-rs/embassy.git", rev = "128575aebe18eea29862c52a88f81671fbcbf610", features = ["defmt", "stm32f411re", "time-driver-any", "exti", "memory-x", "unstable-pac", "chrono"] }
cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] }
chrono = { version = "^0.4", default-features = false }
cortex-m-rt = "0.7.0"
defmt = "0.3"
defmt-rtt = "0.4"
embassy-embedded-hal = { git = "https://github.com/embassy-rs/embassy.git", rev = "128575aebe18eea29862c52a88f81671fbcbf610" }
embassy-executor = { git = "https://github.com/embassy-rs/embassy.git", rev = "128575aebe18eea29862c52a88f81671fbcbf610", features = ["task-arena-size-4096", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "128575aebe18eea29862c52a88f81671fbcbf610" }
embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "128575aebe18eea29862c52a88f81671fbcbf610", features = ["defmt", "defmt-timestamp-uptime"] }
embedded-hal-async = "1.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }

Command line to build:
cargo build --target thumbv7em-none-eabihf

May be needed to compile successfully:
rustup target add thumbv7em-none-eabihf

@perowle
Copy link
Author

perowle commented Jul 1, 2024

Regarding this issue - the simple fix is to add the type to the static variable, and rustc is happy. Just wanted to give you the backtrace in case there's other issues.

@pacak
Copy link
Contributor

pacak commented Jul 1, 2024

Compiler panics with just this

use embassy_sync::blocking_mutex::raw::NoopRawMutex;
use embassy_sync::pubsub::PubSubChannel;

static temperature_channel: _ = PubSubChannel::<NoopRawMutex, f32, 1, 2, 2>::new();

Panic and stack trace looks similar to #124164, both reproducible in current nightly

@saethlin saethlin changed the title rustc backtraces when type not specificed for static variable (Embassy) ICE when type not specificed for static variable (Embassy) Jul 2, 2024
@Noratrieb
Copy link
Member

Noratrieb commented Jul 3, 2024

yeah, this is a duplicate of #124164. closing as such, thank you for the report anyways.

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Jul 3, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 3, 2024
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) ❄️ 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

5 participants