Skip to content

attempted to add with overflow #1370

Closed
Closed
@matthiaskrgr

Description

@matthiaskrgr
// check-pass

const SZ: usize = 64_000_000;
type BigDrop = [String; SZ];

fn f(from_fn: BigDrop) {}

fn f2(_moveme: BigDrop) -> String {
    let [a, ..] = _moveme;
    a
}

fn main() {
    f(std::array::from_fn(|_| String::new()));
    f2(std::array::from_fn(|_| String::new()));
}

cranelift built with debug assertions
rustc -Zcodegen-backend=cranelift file.rs

warning: unused variable: `from_fn`
 --> B3A5F4060827522A3328FC59CAE6348272F5F8B0627152DED589D0B44CBBDBB5.rs:6:6
  |
6 | fn f(from_fn: BigDrop) {}
  |      ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_from_fn`
  |
  = note: `#[warn(unused_variables)]` on by default

thread '<unnamed>' panicked at 'attempt to add with overflow', /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/machinst/abi.rs:1066:13
stack backtrace:
   0:     0x7f9834efeeb0 - std::backtrace_rs::backtrace::libunwind::trace::hbf78ef88fed844ac
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f9834efeeb0 - std::backtrace_rs::backtrace::trace_unsynchronized::h35213943d90d267c
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9834efeeb0 - std::sys_common::backtrace::_print_fmt::h22ba8bfb93a0a925
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f9834efeeb0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4d082456b766373f
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f9834fadec8 - core::fmt::write::he3860e7dd81c785d
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/fmt/mod.rs:1247:17
   5:     0x7f9834f1403f - std::io::Write::write_fmt::he5c3c49e127ce77e
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/io/mod.rs:1712:15
   6:     0x7f9834efecb5 - std::sys_common::backtrace::_print::hbf9982c7c009c352
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f9834efecb5 - std::sys_common::backtrace::print::h8ed700e06ac6907c
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f9834f3d1c3 - std::panicking::default_hook::{{closure}}::h51962e62c530968d
   9:     0x7f9834f3cdf9 - std::panicking::default_hook::h4d87bf54451529eb
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:293:9
  10:     0x7f9837770905 - <alloc[32b43e9536c01a3]::boxed::Box<dyn for<'a, 'b> core[c5d5d662f7508502]::ops::function::Fn<(&'a core[c5d5d662f7508502]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[c5d5d662f7508502]::marker::Send + core[c5d5d662f7508502]::marker::Sync> as core[c5d5d662f7508502]::ops::function::Fn<(&core[c5d5d662f7508502]::panic::panic_info::PanicInfo,)>>::call
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:1976:9
  11:     0x7f9837770905 - rustc_driver_impl[17d9f77bedede00f]::DEFAULT_HOOK::{closure#0}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_driver_impl/src/lib.rs:1208:17
  12:     0x7f9834f3db12 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hadc44a34952fbfd6
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:1976:9
  13:     0x7f9834f3db12 - std::panicking::rust_panic_with_hook::h5a54165269cb41b9
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:704:13
  14:     0x7f9834eff6d5 - std::panicking::begin_panic_handler::{{closure}}::h20e65ba4620c9639
  15:     0x7f9834efef96 - std::sys_common::backtrace::__rust_end_short_backtrace::heb6999246060ea55
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:150:18
  16:     0x7f9834f3d652 - rust_begin_unwind
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:584:5
  17:     0x7f9834fc8373 - core::panicking::panic_fmt::h446694351a19189a
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:67:14
  18:     0x7f9834fc840d - core::panicking::panic::he5f7c6779e1d5164
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panicking.rs:117:5
  19:     0x7f982e905122 - <cranelift_codegen[6b1b02a89ec1a94]::machinst::abi::Callee<cranelift_codegen[6b1b02a89ec1a94]::isa::x64::abi::X64ABIMachineSpec>>::new
  20:     0x7f982e95e2d5 - <cranelift_codegen[6b1b02a89ec1a94]::isa::x64::X64Backend>::compile_vcode
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/isa/x64/mod.rs:56:19
  21:     0x7f982e95e2d5 - <cranelift_codegen[6b1b02a89ec1a94]::isa::x64::X64Backend as cranelift_codegen[6b1b02a89ec1a94]::isa::TargetIsa>::compile_function
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/isa/x64/mod.rs:67:40
  22:     0x7f982e8280a5 - <cranelift_codegen[6b1b02a89ec1a94]::context::Context>::compile_stencil
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/context.rs:143:9
  23:     0x7f982e82887b - <cranelift_codegen[6b1b02a89ec1a94]::context::Context>::compile
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/context.rs:217:23
  24:     0x7f982e827eda - <cranelift_codegen[6b1b02a89ec1a94]::context::Context>::compile_and_emit
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-codegen-0.93.1/src/context.rs:128:29
  25:     0x7f982e7b1b25 - <cranelift_object[7cf3c2d9638365c7]::backend::ObjectModule as cranelift_module[d97cac570ce7dfbe]::module::Module>::define_function
                               at /home/matthias/.cargo/registry/src/hub.490633.xyz-1ecc6299db9ec823/cranelift-object-0.93.0/src/backend.rs:326:19
  26:     0x7f982e6f414d - rustc_codegen_cranelift[c917842f063ff92d]::base::compile_fn::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_codegen_cranelift/src/base.rs:184:9
  27:     0x7f982e6f414d - <rustc_data_structures[e2bc31891c4386a2]::profiling::TimingGuard>::run::<(), rustc_codegen_cranelift[c917842f063ff92d]::base::compile_fn::{closure#0}>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_data_structures/src/profiling.rs:716:9
  28:     0x7f982e6f414d - rustc_codegen_cranelift[c917842f063ff92d]::base::compile_fn
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_codegen_cranelift/src/base.rs:182:53
  29:     0x7f982e697d99 - rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_codegen_cranelift/src/driver/aot.rs:329:21
  30:     0x7f982e697d99 - <rustc_data_structures[e2bc31891c4386a2]::profiling::VerboseTimingGuard>::run::<(), rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}::{closure#0}>
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_data_structures/src/profiling.rs:752:9
  31:     0x7f982e697d99 - rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/compiler/rustc_codegen_cranelift/src/driver/aot.rs:325:96
  32:     0x7f982e697d99 - std[876bbee9698a2b49]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys_common/backtrace.rs:134:18
  33:     0x7f982e731bd9 - <std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_::<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}::{closure#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:526:17
  34:     0x7f982e731bd9 - <core[c5d5d662f7508502]::panic::unwind_safe::AssertUnwindSafe<<std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}::{closure#0}> as core[c5d5d662f7508502]::ops::function::FnOnce<()>>::call_once
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/panic/unwind_safe.rs:271:9
  35:     0x7f982e731bd9 - std[876bbee9698a2b49]::panicking::try::do_call::<core[c5d5d662f7508502]::panic::unwind_safe::AssertUnwindSafe<<std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}::{closure#0}>, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:490:40
  36:     0x7f982e731bd9 - std[876bbee9698a2b49]::panicking::try::<core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>, core[c5d5d662f7508502]::panic::unwind_safe::AssertUnwindSafe<<std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}::{closure#0}>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panicking.rs:454:19
  37:     0x7f982e731bd9 - std[876bbee9698a2b49]::panic::catch_unwind::<core[c5d5d662f7508502]::panic::unwind_safe::AssertUnwindSafe<<std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}::{closure#0}>, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/panic.rs:140:14
  38:     0x7f982e731bd9 - <std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_::<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/thread/mod.rs:525:30
  39:     0x7f982e731bd9 - <<std[876bbee9698a2b49]::thread::Builder>::spawn_unchecked_<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::module_codegen::{closure#1}, core[c5d5d662f7508502]::result::Result<rustc_codegen_cranelift[c917842f063ff92d]::driver::aot::ModuleCodegenResult, alloc[32b43e9536c01a3]::string::String>>::{closure#1} as core[c5d5d662f7508502]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/matthias/vcs/github/rust_debug_assertions/library/core/src/ops/function.rs:250:5
  40:     0x7f9834f0ad7a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h74692b39480ad981
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:1962:9
  41:     0x7f9834f0ad7a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0b92e8b1daec690c
                               at /home/matthias/vcs/github/rust_debug_assertions/library/alloc/src/boxed.rs:1962:9
  42:     0x7f9834f018a5 - std::sys::unix::thread::Thread::new::thread_start::h96fbca9a9a0efa67
                               at /home/matthias/vcs/github/rust_debug_assertions/library/std/src/sys/unix/thread.rs:108:17
  43:     0x7f9834ca1bb5 - <unknown>
  44:     0x7f9834d23d90 - <unknown>
  45:                0x0 - <unknown>

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.71.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z codegen-backend=cranelift

query stack during panic:
end of query stack
warning: 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.upstreamCaused by a dependency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions