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

Out-Of-Range integers in format string literals silently wrap around #102528

Closed
colinba opened this issue Sep 30, 2022 · 0 comments · Fixed by #102529
Closed

Out-Of-Range integers in format string literals silently wrap around #102528

colinba opened this issue Sep 30, 2022 · 0 comments · Fixed by #102529
Labels
C-bug Category: This is a bug.

Comments

@colinba
Copy link
Contributor

colinba commented Sep 30, 2022

I tried this code: (while learning Rust using Rust by Example and experimenting with the format string syntax available via format!() and related macros)

fn main() {
    use std::fmt::format;

    // Note that 18446744073709551616 is usize::MAX + 1

    // Positional Argument
    let s = format(format_args!("{18446744073709551616}", "which arg?"));
    assert!(s == "which arg?");

    // Width
    let s = format(format_args!("{:18446744073709551616}", "wide?"));
    assert!(s == "wide?");

    // Precision
    let s = format(format_args!("{:.18446744073709551616}", "not truncated?"));
    assert!(s == "");
}

I expected to see this happen:

rustc to reject this code with a diagnostic message due to the out of range integers in the format string literals.

Instead, this happened:

rustc compiled the code without any warning or error. Running the generated executable does not produce any assertion errors. This seems to be caused by the integers in the format string literals silently overflowing and wrapping around to zero.

Note that when compiling the code with a selfbuilt debug build of rustc instead of the regular nightly build, rustc panics due to an 'attempt to add with overflow':

Backtrace

$ rustc +stage1 main.rs 
thread 'rustc' panicked at 'attempt to add with overflow', compiler/rustc_parse_format/src/lib.rs:750:23
stack backtrace:
   0:     0x7f765e974d7a - std::backtrace_rs::backtrace::libunwind::trace::h9108d1e1f57ab009
                               at /home/colinba/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f765e974d7a - std::backtrace_rs::backtrace::trace_unsynchronized::he61b1a25a8fa2c93
                               at /home/colinba/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f765e974d7a - std::sys_common::backtrace::_print_fmt::hc3b4a01dee223b9b
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f765e974d7a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h11faa5672e40bdb1
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f765ea12418 - core::fmt::write::hf898e0a9cc3c89a4
                               at /home/colinba/rust/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f765e9749f1 - std::io::Write::write_fmt::h538acf5fc5301699
                               at /home/colinba/rust/library/std/src/io/mod.rs:1679:15
   6:     0x7f765e974bcf - std::sys_common::backtrace::_print::h59ce209c7e800ecd
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f765e974bcf - std::sys_common::backtrace::print::hb8ee3b8311e5882d
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f765e9a4254 - std::panicking::default_hook::{{closure}}::hbfe45ba77109ecee
   9:     0x7f765e9a400a - std::panicking::default_hook::h0e67408afebc1893
                               at /home/colinba/rust/library/std/src/panicking.rs:286:9
  10:     0x7f765aad5644 - <alloc[e0c3f1159f95f7da]::boxed::Box<dyn for<'a, 'b> core[73fa0f4e5d90a029]::ops::function::Fn<(&'a core[73fa0f4e5d90a029]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[73fa0f4e5d90a029]::marker::Send + core[73fa0f4e5d90a029]::marker::Sync> as core[73fa0f4e5d90a029]::ops::function::Fn<(&core[73fa0f4e5d90a029]::panic::panic_info::PanicInfo,)>>::call
                               at /home/colinba/rust/library/alloc/src/boxed.rs:1952:9
  11:     0x7f765aad5644 - rustc_driver[6e01b488aaf869e2]::DEFAULT_HOOK::{closure#0}::{closure#0}
                               at /home/colinba/rust/compiler/rustc_driver/src/lib.rs:1195:13
  12:     0x7f765e9a467d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h277f351db811d6ea
                               at /home/colinba/rust/library/alloc/src/boxed.rs:1952:9
  13:     0x7f765e9a467d - std::panicking::rust_panic_with_hook::ha0dad23d3eb08ebf
                               at /home/colinba/rust/library/std/src/panicking.rs:673:13
  14:     0x7f765e9bb181 - std::panicking::begin_panic_handler::{{closure}}::h6f589be1fbe06c30
                               at /home/colinba/rust/library/std/src/panicking.rs:558:13
  15:     0x7f765e9bb0fc - std::sys_common::backtrace::__rust_end_short_backtrace::hc391446526f574f3
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:138:18
  16:     0x7f765e9a42ba - rust_begin_unwind
                               at /home/colinba/rust/library/std/src/panicking.rs:556:5
  17:     0x7f765e96bb33 - core::panicking::panic_fmt::h73e88d42007178b5
                               at /home/colinba/rust/library/core/src/panicking.rs:142:14
  18:     0x7f765e96b9fd - core::panicking::panic::hf9b007b1905c9b7e
                               at /home/colinba/rust/library/core/src/panicking.rs:48:5
  19:     0x7f765cf57027 - <rustc_parse_format[af8efb4b81c7178d]::Parser>::argument
  20:     0x7f765cf548e2 - <rustc_parse_format[af8efb4b81c7178d]::Parser as core[73fa0f4e5d90a029]::iter::traits::iterator::Iterator>::next
                               at /home/colinba/rust/compiler/rustc_parse_format/src/lib.rs:235:35
  21:     0x7f765b6220a9 - rustc_builtin_macros[d57e03f565254644]::format::make_format_args
                               at /home/colinba/rust/compiler/rustc_builtin_macros/src/format.rs:205:29
  22:     0x7f765b6271f4 - rustc_builtin_macros[d57e03f565254644]::format::expand_format_args_impl
                               at /home/colinba/rust/compiler/rustc_builtin_macros/src/format.rs:852:38
  23:     0x7f765cab67c8 - <rustc_expand[e4dcebcd8da34caf]::expand::MacroExpander>::expand_invoc
                               at /home/colinba/rust/compiler/rustc_expand/src/expand.rs:646:38
  24:     0x7f765cab67c8 - <rustc_expand[e4dcebcd8da34caf]::expand::MacroExpander>::fully_expand_fragment
                               at /home/colinba/rust/compiler/rustc_expand/src/expand.rs:452:62
  25:     0x7f765cab58df - <rustc_expand[e4dcebcd8da34caf]::expand::MacroExpander>::expand_crate
                               at /home/colinba/rust/compiler/rustc_expand/src/expand.rs:379:21
  26:     0x7f765ab7e7d5 - rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}::{closure#1}
                               at /home/colinba/rust/compiler/rustc_interface/src/passes.rs:339:50
  27:     0x7f765ab7e7d5 - <rustc_data_structures[609e4aadb4063e99]::profiling::VerboseTimingGuard>::run::<rustc_ast[6029941c7af2f9e8]::ast::Crate, rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_data_structures/src/profiling.rs:739:9
  28:     0x7f765ab7e7d5 - <rustc_session[413ea26f159cb17f]::session::Session>::time::<rustc_ast[6029941c7af2f9e8]::ast::Crate, rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_session/src/utils.rs:10:9
  29:     0x7f765ab7e7d5 - rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}
                               at /home/colinba/rust/compiler/rustc_interface/src/passes.rs:339:21
  30:     0x7f765ab7e7d5 - <rustc_data_structures[609e4aadb4063e99]::profiling::VerboseTimingGuard>::run::<core[73fa0f4e5d90a029]::result::Result<rustc_ast[6029941c7af2f9e8]::ast::Crate, rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_data_structures/src/profiling.rs:739:9
  31:     0x7f765ab7e7d5 - <rustc_session[413ea26f159cb17f]::session::Session>::time::<core[73fa0f4e5d90a029]::result::Result<rustc_ast[6029941c7af2f9e8]::ast::Crate, rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_interface[4da0135a863180aa]::passes::configure_and_expand::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_session/src/utils.rs:10:9
  32:     0x7f765ab57837 - rustc_interface[4da0135a863180aa]::passes::configure_and_expand
                               at /home/colinba/rust/compiler/rustc_interface/src/passes.rs:291:13
  33:     0x7f765abfa011 - <rustc_interface[4da0135a863180aa]::queries::Queries>::expansion::{closure#0}::{closure#0}
                               at /home/colinba/rust/compiler/rustc_interface/src/queries.rs:182:17
  34:     0x7f765abfa011 - <rustc_interface[4da0135a863180aa]::passes::boxed_resolver::BoxedResolver>::access::<<rustc_interface[4da0135a863180aa]::queries::Queries>::expansion::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result<rustc_ast[6029941c7af2f9e8]::ast::Crate, rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/rust/compiler/rustc_interface/src/passes.rs:135:13
  35:     0x7f765abe08ce - <rustc_interface[4da0135a863180aa]::queries::Queries>::expansion::{closure#0}
                               at /home/colinba/rust/compiler/rustc_interface/src/queries.rs:181:25
  36:     0x7f765abe08ce - <rustc_interface[4da0135a863180aa]::queries::Query<(alloc[e0c3f1159f95f7da]::rc::Rc<rustc_ast[6029941c7af2f9e8]::ast::Crate>, alloc[e0c3f1159f95f7da]::rc::Rc<core[73fa0f4e5d90a029]::cell::RefCell<rustc_interface[4da0135a863180aa]::passes::boxed_resolver::BoxedResolver>>, alloc[e0c3f1159f95f7da]::rc::Rc<rustc_lint[c5ced41158a89e87]::context::LintStore>)>>::compute::<<rustc_interface[4da0135a863180aa]::queries::Queries>::expansion::{closure#0}>
                               at /home/colinba/rust/compiler/rustc_interface/src/queries.rs:38:28
  37:     0x7f765ab69cb9 - <rustc_interface[4da0135a863180aa]::queries::Queries>::expansion
                               at /home/colinba/rust/compiler/rustc_interface/src/queries.rs:170:9
  38:     0x7f765aa9adf6 - rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}::{closure#2}
                               at /home/colinba/rust/compiler/rustc_driver/src/lib.rs:365:13
  39:     0x7f765aa9adf6 - <rustc_interface[4da0135a863180aa]::interface::Compiler>::enter::<rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}::{closure#2}, core[73fa0f4e5d90a029]::result::Result<core[73fa0f4e5d90a029]::option::Option<rustc_interface[4da0135a863180aa]::queries::Linker>, rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/rust/compiler/rustc_interface/src/queries.rs:377:19
  40:     0x7f765aab8052 - rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}
                               at /home/colinba/rust/compiler/rustc_driver/src/lib.rs:316:22
  41:     0x7f765aab8052 - rustc_interface[4da0135a863180aa]::interface::create_compiler_and_run::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#1}
                               at /home/colinba/rust/compiler/rustc_interface/src/interface.rs:323:13
  42:     0x7f765aab8052 - rustc_span[84dbe569a712e516]::with_source_map::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_interface[4da0135a863180aa]::interface::create_compiler_and_run<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_span/src/lib.rs:999:5
  43:     0x7f765aa9ba89 - rustc_interface[4da0135a863180aa]::interface::create_compiler_and_run::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>
                               at /home/colinba/rust/compiler/rustc_interface/src/interface.rs:317:5
  44:     0x7f765aab6142 - rustc_interface[4da0135a863180aa]::interface::run_compiler::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}
                               at /home/colinba/rust/compiler/rustc_interface/src/interface.rs:339:12
  45:     0x7f765aab6142 - <scoped_tls[4b2a4c8958d0f0a7]::ScopedKey<rustc_span[84dbe569a712e516]::SessionGlobals>>::set::<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  46:     0x7f765aaa8eea - rustc_span[84dbe569a712e516]::create_session_globals_then::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}>
                               at /home/colinba/rust/compiler/rustc_span/src/lib.rs:111:5
  47:     0x7f765aaa8eea - rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals::<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}
                               at /home/colinba/rust/compiler/rustc_interface/src/util.rs:159:32
  48:     0x7f765aaa8eea - std[4f84e0109556a123]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/rust/library/std/src/sys_common/backtrace.rs:122:18
  49:     0x7f765aadf6ce - <std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_::<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}::{closure#0}
                               at /home/colinba/rust/library/std/src/thread/mod.rs:514:17
  50:     0x7f765aadf6ce - <core[73fa0f4e5d90a029]::panic::unwind_safe::AssertUnwindSafe<<std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}::{closure#0}> as core[73fa0f4e5d90a029]::ops::function::FnOnce<()>>::call_once
                               at /home/colinba/rust/library/core/src/panic/unwind_safe.rs:271:9
  51:     0x7f765aadf6ce - std[4f84e0109556a123]::panicking::try::do_call::<core[73fa0f4e5d90a029]::panic::unwind_safe::AssertUnwindSafe<<std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/rust/library/std/src/panicking.rs:464:40
  52:     0x7f765aadf6ce - std[4f84e0109556a123]::panicking::try::<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, core[73fa0f4e5d90a029]::panic::unwind_safe::AssertUnwindSafe<<std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}::{closure#0}>>
                               at /home/colinba/rust/library/std/src/panicking.rs:428:19
  53:     0x7f765aacdf74 - std[4f84e0109556a123]::panic::catch_unwind::<core[73fa0f4e5d90a029]::panic::unwind_safe::AssertUnwindSafe<<std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>
                               at /home/colinba/rust/library/std/src/panic.rs:137:14
  54:     0x7f765aacdf74 - <std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_::<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1}
                               at /home/colinba/rust/library/std/src/thread/mod.rs:513:30
  55:     0x7f765aacdf74 - <<std[4f84e0109556a123]::thread::Builder>::spawn_unchecked_<rustc_interface[4da0135a863180aa]::util::run_in_thread_pool_with_globals<rustc_interface[4da0135a863180aa]::interface::run_compiler<core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>, rustc_driver[6e01b488aaf869e2]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[569c0348dc576e4]::ErrorGuaranteed>>::{closure#1} as core[73fa0f4e5d90a029]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
                               at /home/colinba/rust/library/core/src/ops/function.rs:251:5
  56:     0x7f765e986018 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9acdd6282553a5d8
                               at /home/colinba/rust/library/alloc/src/boxed.rs:1938:9
  57:     0x7f765e986018 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf6a1ef571f76545d
                               at /home/colinba/rust/library/alloc/src/boxed.rs:1938:9
  58:     0x7f765e9b3727 - std::sys::unix::thread::Thread::new::thread_start::h1c6f062e9a3e87c6
                               at /home/colinba/rust/library/std/src/sys/unix/thread.rs:108:17
  59:     0x7f7659e8ce2d - start_thread
  60:     0x7f7659f121b0 - __clone3
  61:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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

query stack during panic:
end of query stack

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (9c56d9d6f 2022-09-29)
binary: rustc
commit-hash: 9c56d9d6fec6262bbb1549cfe466a812ae2c6523
commit-date: 2022-09-29
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0
@colinba colinba added the C-bug Category: This is a bug. label Sep 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 14, 2022
Detect and reject out-of-range integers in format string literals

Until now out-of-range integers in format string literals were silently ignored. They wrapped around to zero at usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string literals even cause an 'attempt to add with overflow' panic in rustc.

Fix this by producing an error diagnostic for integers in format string literals which do not fit into usize.

Fixes rust-lang#102528
@bors bors closed this as completed in b9e85bf Oct 14, 2022
lyming2007 pushed a commit to lyming2007/rust that referenced this issue Oct 21, 2022
Until now out-of-range integers in format string literals
were silently ignored. They wrapped around to zero at
usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string
literals even cause an 'attempt to add with overflow' panic in
rustc.

Fix this by producing an error diagnostic for integers in format
string literals which do not fit into usize.

Fixes rust-lang#102528
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
Detect and reject out-of-range integers in format string literals

Until now out-of-range integers in format string literals were silently ignored. They wrapped around to zero at usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string literals even cause an 'attempt to add with overflow' panic in rustc.

Fix this by producing an error diagnostic for integers in format string literals which do not fit into usize.

Fixes rust-lang#102528
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant