Skip to content

Manual Slice Size Calculation with DSTs ICE #14802

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

Open
stegaBOB opened this issue May 14, 2025 · 1 comment · May be fixed by #14804
Open

Manual Slice Size Calculation with DSTs ICE #14802

stegaBOB opened this issue May 14, 2025 · 1 comment · May be fixed by #14804
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@stegaBOB
Copy link

stegaBOB commented May 14, 2025

Summary

Required code to trigger ICE:

struct IcedSlice {
    dst: [u8],
}

impl IcedSlice {
    fn get_len(&self) -> usize {
        self.dst.len() * size_of::<u8>()
    }
}

Version

rustc 1.89.0-nightly (8405332bd 2025-05-12)
binary: rustc
commit-hash: 8405332bdf09b153e475f83b8b8ebf8d4e8eb81f
commit-date: 2025-05-12
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.4

Error output

Backtrace

thread 'rustc' panicked at /rustc/8405332bdf09b153e475f83b8b8ebf8d4e8eb81f/library/alloc/src/slice.rs:523:23:
capacity overflow
stack backtrace:
 0:     0x722195869765 - std::backtrace::Backtrace::create::h0248f45dee27e8e8
 1:     0x722193d43ab5 - std::backtrace::Backtrace::force_capture::h541739a45a1c2ff6
 2:     0x722192d8b3a1 - std[a3033ab4cf040dbc]::panicking::update_hook::<alloc[2b9f1e9988cc0e0]::boxed::Box<rustc_driver_impl[2b29d548aa47efe8]::install_ice_hook::{closure#1}>>::{closure#0}
 3:     0x722193d5d993 - std::panicking::rust_panic_with_hook::h614c9e3cb602169a
 4:     0x722193d5d656 - std::panicking::begin_panic_handler::{{closure}}::h7175c42c4098b33c
 5:     0x722193d59b89 - std::sys::backtrace::__rust_end_short_backtrace::hb28ab4ef577ce3dd
 6:     0x722193d5d34d - __rustc[9e838b297ad6583e]::rust_begin_unwind
 7:     0x722190686220 - core::panicking::panic_fmt::hee3e8e41a6e23382
 8:     0x7221926accf7 - alloc::raw_vec::capacity_overflow::h84f1def4b28fd01f
 9:     0x7221911f0d28 - alloc::raw_vec::handle_error::h79a2077f49fb9d94
10:     0x5c77a05bbc65 - <[u8]>::repeat
11:     0x5c77a0720b12 - <clippy_lints[8dfab32cf038f23c]::manual_slice_size_calculation::ManualSliceSizeCalculation as rustc_lint[8bf7ab06bda0f1b1]::passes::LateLintPass>::check_expr
12:     0x7221933078de - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
13:     0x722193307847 - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_expr
14:     0x722193308c0b - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_block
15:     0x722193307fa7 - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
16:     0x722193307847 - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_expr
17:     0x722193307682 - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_nested_body
18:     0x7221933082ee - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_fn
19:     0x7221932ef7e2 - <rustc_lint[8bf7ab06bda0f1b1]::late::LateContextAndPass<rustc_lint[8bf7ab06bda0f1b1]::late::RuntimeCombinedLateLintPass> as rustc_hir[a71df458abc79d8]::intravisit::Visitor>::visit_nested_item
20:     0x7221953dcfde - rustc_lint[8bf7ab06bda0f1b1]::late::check_crate::{closure#0}
21:     0x7221953dd289 - rustc_lint[8bf7ab06bda0f1b1]::late::check_crate
22:     0x7221953db59f - rustc_interface[b13b618c5853daff]::passes::analysis
23:     0x7221953db375 - rustc_query_impl[c99fb05ce5425a5b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c99fb05ce5425a5b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[c35c93541fbaf6fb]::query::erase::Erased<[u8; 0usize]>>
24:     0x7221953d5e44 - rustc_query_system[13fd671b9de95920]::query::plumbing::try_execute_query::<rustc_query_impl[c99fb05ce5425a5b]::DynamicConfig<rustc_query_system[13fd671b9de95920]::query::caches::SingleCache<rustc_middle[c35c93541fbaf6fb]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c99fb05ce5425a5b]::plumbing::QueryCtxt, true>
25:     0x7221953d5768 - rustc_query_impl[c99fb05ce5425a5b]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
26:     0x72219561f0c7 - rustc_interface[b13b618c5853daff]::passes::create_and_enter_global_ctxt::<core[844c48195e089da5]::option::Option<rustc_interface[b13b618c5853daff]::queries::Linker>, rustc_driver_impl[2b29d548aa47efe8]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
27:     0x7221954f50a6 - rustc_interface[b13b618c5853daff]::interface::run_compiler::<(), rustc_driver_impl[2b29d548aa47efe8]::run_compiler::{closure#0}>::{closure#1}
28:     0x7221954ca07e - std[a3033ab4cf040dbc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[b13b618c5853daff]::util::run_in_thread_with_globals<rustc_interface[b13b618c5853daff]::util::run_in_thread_pool_with_globals<rustc_interface[b13b618c5853daff]::interface::run_compiler<(), rustc_driver_impl[2b29d548aa47efe8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
29:     0x7221954ca4eb - <<std[a3033ab4cf040dbc]::thread::Builder>::spawn_unchecked_<rustc_interface[b13b618c5853daff]::util::run_in_thread_with_globals<rustc_interface[b13b618c5853daff]::util::run_in_thread_pool_with_globals<rustc_interface[b13b618c5853daff]::interface::run_compiler<(), rustc_driver_impl[2b29d548aa47efe8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[844c48195e089da5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
30:     0x7221954cb8eb - std::sys::pal::unix::thread::Thread::new::thread_start::hcb4e67cfc7257238
31:     0x72218f09caa4 - start_thread
                             at ./nptl/pthread_create.c:447:8
32:     0x72218f129c3c - clone3
                             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
33:                0x0 - <unknown>


rustc version: 1.89.0-nightly (8405332bd 2025-05-12)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack

@stegaBOB stegaBOB added C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️ labels May 14, 2025
@samueltardieu
Copy link
Contributor

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-ICE Issue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants