Skip to content

rustc paniced at Box<Any> #78886

Closed
Closed
@Qubasa

Description

@Qubasa

The panic happened as I tried to de reference the generic type Tin size_of::<*T>()

Code

    unsafe fn verify_checksum<T: Sized>(
        &self,
        mapper: &mut OffsetPageTable,
        frame_allocator: &mut impl FrameAllocator<Size4KiB>,
        table: &T
        ) -> bool {

        // ERROR IS HERE                    |
        let table_bytes: &[u8; size_of::<*T>()] =
            core::intrinsics::transmute(&table);
        let sum = table_bytes
            .iter()
            .fold(0_u8, |acc, &elem| acc.wrapping_add(elem));
        if sum != 0 {
            return false;
        }
        return true;
    }

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)
binary: rustc
commit-hash: ffa2e7ae8fbf9badc035740db949b9dae271c29f
commit-date: 2020-10-24
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly
LLVM version: 11.0

Error output

error: expected mut or const in raw pointer type
  --> src/acpi.rs:78:42
   |
78 |         let table_bytes: &[u8; size_of::<*T>()] =
   |                                          ^ expected mut or const in raw pointer type
   |
   = help: use `*mut T` or `*const T` as appropriate

^[[Berror: internal compiler error: compiler/rustc_middle/src/ty/subst.rs:528:17: type parameter `T/#0` (T/0) out of range when substituting, substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/ffa2e7ae8fbf9badc035740db949b9dae271c29f/compiler/rustc_errors/src/lib.rs:891:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: 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.49.0-nightly (ffa2e7ae8 2020-10-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native --crate-type lib

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

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `acpi::Acpi::verify_checksum::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `acpi::Acpi::verify_checksum::{constant#0}`
end of query stack
error: aborting due to 2 previous errors

error: could not compile `svm_kernel`

To learn more, run the command again with --verbose.
Error: Kernel build failed.
Stderr: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions