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

ICE: compiler/rustc_mir/src/interpret/validity.rs:948:17: Unexpected error during validation: unable to turn pointer into raw bytes #83182

Closed
chengniansun opened this issue Mar 16, 2021 · 6 comments · Fixed by #85332
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) 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-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

use std::mem;
struct MyStr(str);
const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
fn main() {}

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (107896c32 2021-03-15)
binary: rustc
commit-hash: 107896c32d5dda4db508968ff34997a39d286966
commit-date: 2021-03-15
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

Error output

warning: struct is never constructed: `MyStr`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:8
  |
2 | struct MyStr(str);
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: constant is never used: `MYSTR_NO_INIT`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_mir/src/interpret/validity.rs:948:17: Unexpected error during validation: unable to turn pointer into raw bytes

thread 'rustc' panicked at 'Box<Any>', /rustc/107896c32d5dda4db508968ff34997a39d286966/library/std/src/panic.rs:59:5
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.52.0-nightly (107896c32 2021-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `MYSTR_NO_INIT`
#1 [eval_to_const_value_raw] simplifying constant for the type system `MYSTR_NO_INIT`
end of query stack
error: aborting due to previous error; 2 warnings emitted
Backtrace

warning: struct is never constructed: `MyStr`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:2:8
  |
2 | struct MyStr(str);
  |        ^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: constant is never used: `MYSTR_NO_INIT`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1
  |
3 | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_mir/src/interpret/validity.rs:948:17: Unexpected error during validation: unable to turn pointer into raw bytes

thread 'rustc' panicked at 'Box<Any>', /rustc/107896c32d5dda4db508968ff34997a39d286966/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: rustc_mir::interpret::validity::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::validate_operand_internal
   8: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
   9: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_allocation_raw>::compute
  10: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  11: rustc_data_structures::stack::ensure_sufficient_stack
  12: rustc_query_system::query::plumbing::force_query_with_job
  13: rustc_query_system::query::plumbing::get_query_impl
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_allocation_raw
  15: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  16: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_const_value_raw>::compute
  17: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  18: rustc_data_structures::stack::ensure_sufficient_stack
  19: rustc_query_system::query::plumbing::force_query_with_job
  20: rustc_query_system::query::plumbing::get_query_impl
  21: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  22: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  23: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::eval_to_const_value_raw>::compute
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_data_structures::stack::ensure_sufficient_stack
  26: rustc_query_system::query::plumbing::force_query_with_job
  27: rustc_query_system::query::plumbing::get_query_impl
  28: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::eval_to_const_value_raw
  29: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_global_id
  30: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly
  31: <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item
  32: rustc_hir::intravisit::Visitor::visit_nested_item
  33: rustc_hir::intravisit::walk_crate
  34: rustc_session::utils::<impl rustc_session::session::Session>::time
  35: std::panic::catch_unwind
  36: rustc_session::utils::<impl rustc_session::session::Session>::time
  37: rustc_interface::passes::analysis
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_data_structures::stack::ensure_sufficient_stack
  40: rustc_query_system::query::plumbing::force_query_with_job
  41: rustc_query_system::query::plumbing::get_query_impl
  42: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  43: rustc_interface::passes::QueryContext::enter
  44: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  45: rustc_span::with_source_map
  46: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.52.0-nightly (107896c32 2021-03-15) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `MYSTR_NO_INIT`
#1 [eval_to_const_value_raw] simplifying constant for the type system `MYSTR_NO_INIT`
#2 [eval_to_const_value_raw] simplifying constant for the type system `MYSTR_NO_INIT`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error; 2 warnings emitted

@chengniansun chengniansun 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 Mar 16, 2021
@jonas-schievink jonas-schievink added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 16, 2021
@hameerabbasi
Copy link
Contributor

Bisected:

********************************************************************************
Regression in nightly-2020-07-13
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-07-12/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-07-12: 40 B / 40 B [===============] 100.00 % 709.18 KB/s converted 2020-07-12 to 346aec9b02f3c74f3fce97fd6bda24709d220e49
fetching https://static.rust-lang.org/dist/2020-07-13/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-07-13: 40 B / 40 B [===============] 100.00 % 653.00 KB/s converted 2020-07-13 to 9d09331e00b02f81c714b0c41ce3a38380dd36a2
looking for regression commit between 2020-07-12 and 2020-07-13
opening existing repository at "rust.git"
refreshing repository
fetching (via local git) commits from 346aec9b02f3c74f3fce97fd6bda24709d220e49 to 9d09331e00b02f81c714b0c41ce3a38380dd36a2
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 2 bors merge commits in the specified range
  commit[0] 2020-07-11UTC: Auto merge of #74235 - Manishearth:rollup-bgs3q14, r=Manishearth
  commit[1] 2020-07-12UTC: Auto merge of #74245 - Manishearth:rollup-r0xq9dn, r=Manishearth

@jyn514 jyn514 added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Mar 16, 2021
@apiraino
Copy link
Contributor

@chengniansun By looking at the error message, could this issue be a duplicate of #79690 or #72113?

(Or, in other words, I wonder if we should consider either one ot those two issues related and reopen them)

@apiraino
Copy link
Contributor

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 17, 2021
@chengniansun
Copy link
Author

Hi @apiraino

I think this is not a duplicate, mainly because the two other issues have been fixed and closed.

But if the root cause is the same as the other two, whether this is a duplicate depends on the usual workflow of the rust project.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 17, 2021
@RalfJung
Copy link
Member

Backtrace of the underlying CTFE error with line numbers (generated by setting RUSTC_CTFE_BACKTRACE=1):

An error occurred in miri:
   0: <rustc_middle::mir::interpret::error::InterpErrorInfo as core::convert::From<rustc_middle::mir::interpret::error::InterpError>>::from
             at ./compiler/rustc_middle/src/mir/interpret/error.rs:118:53
   1: rustc_middle::mir::interpret::allocation::Allocation<Tag,Extra>::get_bytes_internal
   2: rustc_middle::mir::interpret::allocation::Allocation<Tag,Extra>::get_bytes
             at ./compiler/rustc_middle/src/mir/interpret/allocation.rs:237:9
      rustc_mir::interpret::memory::Memory<M>::read_bytes
             at ./compiler/rustc_mir/src/interpret/memory.rs:804:9
   3: <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_aggregate
             at ./compiler/rustc_mir/src/interpret/validity.rs:833:21
      rustc_mir::interpret::visitor::ValueVisitor::walk_value
             at ./compiler/rustc_mir/src/interpret/visitor.rs:252:25
   4: <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_value
             at ./compiler/rustc_mir/src/interpret/validity.rs:788:9
   5: <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_field::{{closure}}
             at ./compiler/rustc_mir/src/interpret/validity.rs:739:42
      rustc_mir::interpret::validity::ValidityVisitor<M>::with_elem
             at ./compiler/rustc_mir/src/interpret/validity.rs:311:17
      <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_field
             at ./compiler/rustc_mir/src/interpret/validity.rs:739:9
   6: rustc_mir::interpret::visitor::ValueVisitor::walk_aggregate
             at ./compiler/rustc_mir/src/interpret/visitor.rs:201:21
      <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_aggregate
             at ./compiler/rustc_mir/src/interpret/validity.rs:917:17
      rustc_mir::interpret::visitor::ValueVisitor::walk_value
             at ./compiler/rustc_mir/src/interpret/visitor.rs:240:25
   7: <rustc_mir::interpret::validity::ValidityVisitor<M> as rustc_mir::interpret::visitor::ValueVisitor<M>>::visit_value
             at ./compiler/rustc_mir/src/interpret/validity.rs:788:9
      rustc_mir::interpret::validity::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::validate_operand_internal
             at ./compiler/rustc_mir/src/interpret/validity.rs:941:15
   8: rustc_mir::interpret::validity::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::const_validate_operand
             at ./compiler/rustc_mir/src/interpret/validity.rs:974:9
      rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
             at ./compiler/rustc_mir/src/const_eval/eval_queries.rs:352:21

This call

self.ecx.memory.read_bytes(mplace.ptr, Size::from_bytes(len)),

needs to also handle ReadPointerAsBytes errors.

@RalfJung
Copy link
Member

I'm working on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) 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-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

8 participants