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

thread 'rustc' panicked at 'f64 failed to parse 9E: ParseFloatError { kind: Invalid }' #91434

Closed
Badel2 opened this issue Dec 1, 2021 · 3 comments · Fixed by #91791
Closed
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Badel2
Copy link
Contributor

Badel2 commented Dec 1, 2021

I'm seeing an internal compiler error on the following input, found by fuzz-rustc:

Code

fn main() {
    [9; [[9E; h]]];
}

Error output

error: expected at least one digit in exponent
 --> src/main.rs:2:11
  |
2 |     [9; [[9E; h]]];
  |           ^^

error[E0425]: cannot find value `h` in this scope
 --> src/main.rs:2:15
  |
2 |     [9; [[9E; h]]];
  |               ^ not found in this scope

thread 'rustc' panicked at 'f64 failed to parse `9E`: ParseFloatError { kind: Invalid }', compiler/rustc_mir_build/src/thir/constant.rs:87:37

The ICE happens after correctly reporting a malformed float error, so low priority. Note that slight modifications of the input fix the panic. For example using 0 instead of h results in no panic. Also there is no panic if compling only the string [9E; h]. Affected versions: I tried nightly 2021-11-30 and stable 1.56.1 and they both show the same ICE.

Backtrace

   Compiling playground v0.0.1 (/playground)
error: expected at least one digit in exponent
 --> src/main.rs:2:11
  |
2 |     [9; [[9E; h]]];
  |           ^^

error[E0425]: cannot find value `h` in this scope
 --> src/main.rs:2:15
  |
2 |     [9; [[9E; h]]];
  |               ^ not found in this scope

thread 'rustc' panicked at 'f64 failed to parse `9E`: ParseFloatError { kind: Invalid }', compiler/rustc_mir_build/src/thir/constant.rs:87:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/207c80f105282245d93024c95ac408c622f70114/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/207c80f105282245d93024c95ac408c622f70114/library/core/src/panicking.rs:107:14
   2: rustc_mir_build::thir::constant::lit_to_const
   3: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::mir::interpret::LitToConstInput, core::result::Result<&rustc_middle::ty::consts::Const, rustc_middle::mir::interpret::LitToConstError>>>
   4: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::lit_to_const
   5: <rustc_mir_build::thir::cx::Cx>::mirror_expr_inner
   6: <rustc_mir_build::thir::cx::Cx>::mirror_expr_inner
   7: <rustc_mir_build::thir::cx::Cx>::mirror_expr_inner
   8: rustc_mir_build::thir::cx::thir_body
   9: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::WithOptConstParam<rustc_span::def_id::LocalDefId>, (&rustc_data_structures::steal::Steal<rustc_middle::thir::Thir>, rustc_middle::thir::ExprId)>>
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::thir_body
  11: <rustc_infer::infer::InferCtxtBuilder>::enter::<rustc_middle::mir::Body, rustc_mir_build::build::mir_build::{closure#1}>
  12: rustc_mir_build::build::mir_built
  13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::WithOptConstParam<rustc_span::def_id::LocalDefId>, &rustc_data_structures::steal::Steal<rustc_middle::mir::Body>>>
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built
  15: rustc_mir_transform::check_unsafety::unsafety_check_result
  16: <rustc_mir_transform::check_unsafety::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>>
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
  19: rustc_mir_transform::mir_const
  20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::WithOptConstParam<rustc_span::def_id::LocalDefId>, &rustc_data_structures::steal::Steal<rustc_middle::mir::Body>>>
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
  22: <rustc_mir_transform::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId)>>::call_once
  23: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::mir::query::ConstQualifs>>
  24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const_qualif
  25: rustc_const_eval::const_eval::eval_queries::eval_to_allocation_raw_provider
  26: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::eval_to_allocation_raw, rustc_query_impl::plumbing::QueryCtxt>
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  28: rustc_const_eval::const_eval::eval_queries::eval_to_const_value_raw_provider
  29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::mir::interpret::GlobalId>, core::result::Result<rustc_middle::mir::interpret::value::ConstValue, rustc_middle::mir::interpret::error::ErrorHandled>>>
  30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  31: <rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  32: <rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  33: <rustc_infer::infer::InferCtxt>::const_eval_resolve
  34: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
  35: <rustc_trait_selection::traits::fulfill::FulfillProcessor>::progress_changed_obligations
  36: <rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor, rustc_data_structures::obligation_forest::Outcome<rustc_trait_selection::traits::fulfill::PendingPredicateObligation, rustc_infer::traits::FulfillmentErrorCode>>
  37: <rustc_trait_selection::traits::fulfill::FulfillmentContext as rustc_infer::traits::engine::TraitEngine>::select_with_constness_where_possible
  38: <rustc_typeck::check::fn_ctxt::FnCtxt>::type_inference_fallback
  39: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  40: rustc_typeck::check::typeck
  41: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  42: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  43: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_typeck::check::typeck_item_bodies::{closure#0}>
  44: rustc_typeck::check::typeck_item_bodies
  45: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  46: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  47: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  48: rustc_typeck::check_crate
  49: rustc_interface::passes::analysis
  50: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  51: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  52: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  53: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  54: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  55: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.59.0-nightly (207c80f10 2021-11-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

query stack during panic:
#0 [lit_to_const] converting literal to const
#1 [thir_body] building THIR for `main::{constant#0}`
#2 [mir_built] building MIR for `main::{constant#0}`
#3 [unsafety_check_result] unsafety-checking `main::{constant#0}`
#4 [mir_const] processing MIR for `main::{constant#0}`
#5 [mir_const_qualif] const checking `main::{constant#0}`
#6 [eval_to_allocation_raw] const-evaluating + checking `main::{constant#0}`
#7 [eval_to_const_value_raw] simplifying constant for the type system `main::{constant#0}`
#8 [typeck] type-checking `main`
#9 [typeck_item_bodies] type-checking all item bodies
#10 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0425`.
error: could not compile `playground` due to 2 previous errors

@Badel2 Badel2 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 Dec 1, 2021
@workingjubilee workingjubilee added the P-low Low priority label Dec 2, 2021
@terrarier2111
Copy link
Contributor

@rustbot claim

@chadbrewbaker
Copy link

Might be related? apache/arrow-rs#1043 (comment)

Formatting of "1e-15" behavior seems to have changed on nightly for f64 and f32.

@Badel2
Copy link
Contributor Author

Badel2 commented Dec 15, 2021

It may have a common cause, but you should open a separate issue because the pull request that fixes this doesn't fix your problem.

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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants