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

rustc paniced at Box<Any> #78886

Closed
Qubasa opened this issue Nov 8, 2020 · 1 comment
Closed

rustc paniced at Box<Any> #78886

Qubasa opened this issue Nov 8, 2020 · 1 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.

Comments

@Qubasa
Copy link

Qubasa commented Nov 8, 2020

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: 

@Qubasa Qubasa 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 Nov 8, 2020
@jonas-schievink
Copy link
Contributor

Duplicate of #43408

@jonas-schievink jonas-schievink marked this as a duplicate of #43408 Nov 8, 2020
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

2 participants