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

Internal compiler error on mutable stable slice #46604

Closed
EPashkin opened this issue Dec 9, 2017 · 3 comments
Closed

Internal compiler error on mutable stable slice #46604

EPashkin opened this issue Dec 9, 2017 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@EPashkin
Copy link
Contributor

EPashkin commented Dec 9, 2017

Internal compiler error on
rustc 1.22.1 (05e2e1c 2017-11-22) running on x86_64-pc-windows-gnu
rustc 1.24.0-nightly (0a2e9ad 2017-11-29) running on x86_64-pc-windows-gnu
also on playground
rustc 1.22.1 (05e2e1c 2017-11-22) running on x86_64-unknown-linux-gnu
rustc 1.23.0-beta.2 (c9107ee 2017-12-08) running on x86_64-unknown-linux-gnu
rustc 1.24.0-nightly (ad3543d 2017-12-08) running on x86_64-unknown-linux-gnu

I tried this code in empty lib crate:

static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];

fn tst() {
    unsafe {
        write(&buf);
        buf[0]=2;
    }
}

fn write<T: AsRef<[u8]>/* + Send*/>(buffer: T) { }

I expected see only message "statics require immutable values".
Instead I see

error[E0017]: references in statics may only refer to immutable values
 --> lib.rs:1:25
  |
1 | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];
  |                         ^^^^^^^^^^^^^^^^^^^^ statics require immutable values

error[E0017]: references in statics may only refer to immutable values
 --> lib.rs:1:25
  |
1 | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];
  |                         ^^^^^^^^^^^^^^^^^^^^ statics require immutable values

error: internal compiler error: src\librustc_borrowck\borrowck\mod.rs:1050: aliasability violation for static `cannot assign to data`
 --> lib.rs:6:9
  |
6 |         buf[0]=2;
  |         ^^^^^^^^

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.22.1 (05e2e1c41 2017-11-22) running on x86_64-pc-windows-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:439:8
stack backtrace:
   0: mingw_set_invalid_parameter_handler
   1: mingw_set_invalid_parameter_handler
   2: mingw_set_invalid_parameter_handler
   3: mingw_set_invalid_parameter_handler
   4: mingw_set_invalid_parameter_handler
   5: mingw_set_invalid_parameter_handler
   6: mingw_set_invalid_parameter_handler
   7: mingw_set_invalid_parameter_handler
   8: mingw_set_invalid_parameter_handler
   9: mingw_set_invalid_parameter_handler
  10: mingw_set_invalid_parameter_handler
  11: mingw_set_invalid_parameter_handler
  12: mingw_set_invalid_parameter_handler
  13: mingw_set_invalid_parameter_handler
  14: mingw_set_invalid_parameter_handler
  15: mingw_set_invalid_parameter_handler
  16: mingw_set_invalid_parameter_handler
  17: mingw_set_invalid_parameter_handler
  18: mingw_set_invalid_parameter_handler
  19: mingw_set_invalid_parameter_handler
  20: mingw_set_invalid_parameter_handler
  21: mingw_set_invalid_parameter_handler
  22: mingw_set_invalid_parameter_handler
  23: mingw_set_invalid_parameter_handler
  24: mingw_set_invalid_parameter_handler
  25: mingw_set_invalid_parameter_handler
  26: mingw_set_invalid_parameter_handler
  27: mingw_set_invalid_parameter_handler
  28: mingw_set_invalid_parameter_handler
  29: mingw_set_invalid_parameter_handler
  30: mingw_set_invalid_parameter_handler
  31: mingw_set_invalid_parameter_handler
  32: mingw_set_invalid_parameter_handler
  33: mingw_set_invalid_parameter_handler
  34: mingw_set_invalid_parameter_handler
  35: mingw_set_invalid_parameter_handler

Full version:
rustc 1.22.1 (05e2e1c 2017-11-22)
binary: rustc
commit-hash: 05e2e1c
commit-date: 2017-11-22
host: x86_64-pc-windows-gnu
release: 1.22.1
LLVM version: 4.0

rustc 1.24.0-nightly (0a2e9ad 2017-11-29)
binary: rustc
commit-hash: 0a2e9ad
commit-date: 2017-11-29
host: x86_64-pc-windows-gnu
release: 1.24.0-nightly
LLVM version: 4.0

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 9, 2017
@DemiMarie
Copy link
Contributor

First, obviously the backtrace is borked.

@EPashkin
Copy link
Contributor Author

Yes it broken, but I can't get better 😢

@Deewiant
Copy link
Contributor

Deewiant commented Dec 22, 2017

I tried to bisect this but turns out that it was introduced long enough ago that I had trouble getting those versions to build. (c033942 is the oldest commit I can build since the Cargo version specified in src/stage0.txt can no longer be downloaded, and I don't know an easy way of getting around this.)

So I turned to release binaries instead. After modifying the first line to explicitly specify the lifetime (static buf: &'static mut [u8] = &mut [1u8,2,3,4,5,7];) so that older Rust accepts the code, in the end I found that the ICE was introduced somewhere between 1.16.0 and 1.17.0.

Here's a proper backtrace from master (ba27415):


<snip>
error: internal compiler error: src/librustc_borrowck/borrowck/mod.rs:1091: aliasability violation for static `cannot assign to data`
<snip>
thread 'rustc' panicked at 'Box', src/librustc_errors/lib.rs:449:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:68
             at src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at ./src/libstd/panicking.rs:538
   6: rustc_errors::Handler::span_bug
             at ./:3
   7: >::with
             at ./src/librustc/session/mod.rs:1125
             at ./src/librustc/ty/context.rs:1587
             at ./src/librustc/ty/context.rs:1576
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
   8: rustc::ty::context::tls::with_opt
             at ./src/librustc/ty/context.rs:1572
             at ./src/librustc/ty/context.rs:1587
   9: rustc::session::span_bug_fmt
             at ./src/librustc/session/mod.rs:1122
             at ./src/librustc/session/mod.rs:1115
  10: rustc_borrowck::borrowck::BorrowckCtxt::report_aliasability_violation
             at src/librustc_borrowck/borrowck/mod.rs:1091
  11: rustc_borrowck::borrowck::gather_loans::check_aliasability
             at src/librustc_borrowck/borrowck/gather_loans/mod.rs:192
  12:  as rustc::middle::expr_use_visitor::Delegate<'tcx>>::mutate
             at src/librustc_borrowck/borrowck/gather_loans/mod.rs:268
             at src/librustc_borrowck/borrowck/gather_loans/mod.rs:150
  13: rustc::middle::expr_use_visitor::ExprUseVisitor::mutate_expr
             at src/librustc/middle/expr_use_visitor.rs:365
  14: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
             at src/librustc/middle/expr_use_visitor.rs:516
  15: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
             at src/librustc/middle/expr_use_visitor.rs:357
  16: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_block
             at src/librustc/middle/expr_use_visitor.rs:606
             at src/librustc/middle/expr_use_visitor.rs:638
  17: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
             at src/librustc/middle/expr_use_visitor.rs:0
  18: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
             at src/librustc/middle/expr_use_visitor.rs:357
  19: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_block
             at src/librustc/middle/expr_use_visitor.rs:642
  20: rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr
             at src/librustc/middle/expr_use_visitor.rs:0
  21: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_expr
             at src/librustc/middle/expr_use_visitor.rs:357
  22: rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body
             at src/librustc/middle/expr_use_visitor.rs:328
  23: rustc_borrowck::borrowck::gather_loans::gather_loans_in_fn
             at src/librustc_borrowck/borrowck/gather_loans/mod.rs:52
  24: rustc_borrowck::borrowck::borrowck
             at src/librustc_borrowck/borrowck/mod.rs:168
             at src/librustc_borrowck/borrowck/mod.rs:138
  25: rustc::ty::maps::>::compute_result
             at src/librustc/ty/maps/plumbing.rs:383
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
             at src/librustc/dep_graph/graph.rs:273
  27: rustc::dep_graph::graph::DepGraph::with_task
             at src/librustc/dep_graph/graph.rs:189
  28: rustc_errors::Handler::track_diagnostics
             at src/librustc/ty/maps/plumbing.rs:492
             at ./src/librustc_errors/lib.rs:565
  29: rustc::ty::maps::plumbing::>::cycle_check
             at src/librustc/ty/maps/plumbing.rs:485
             at src/librustc/ty/maps/plumbing.rs:121
  30: rustc::ty::maps::>::force
             at src/librustc/ty/maps/plumbing.rs:484
  31: rustc::ty::maps::>::try_get
             at src/librustc/ty/maps/plumbing.rs:301
             at src/librustc/ty/maps/plumbing.rs:526
  32: rustc::ty::maps::TyCtxtAt::borrowck
             at src/librustc/ty/maps/plumbing.rs:565
  33: rustc::ty::maps::>::borrowck
             at src/librustc/ty/maps/plumbing.rs:558
  34: rustc_borrowck::borrowck::check_crate
             at src/librustc_borrowck/borrowck/mod.rs:70
  35: >::with
             at src/librustc_driver/driver.rs:1080
             at ./src/librustc/ty/context.rs:1560
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
  36: rustc::ty::context::tls::enter
             at ./src/librustc/ty/context.rs:1557
  37: >::with
             at ./src/librustc/ty/context.rs:1544
             at ./src/libstd/thread/local.rs:377
             at ./src/libstd/thread/local.rs:288
  38: rustc::ty::context::TyCtxt::create_and_enter
             at ./src/librustc/ty/context.rs:1541
             at ./src/librustc/ty/context.rs:1184
  39: rustc_driver::driver::compile_input
             at src/librustc_driver/driver.rs:1033
             at src/librustc_driver/driver.rs:227
  40: rustc_driver::run_compiler
             at src/librustc_driver/lib.rs:253

bors added a commit that referenced this issue Jan 2, 2018
…estebank

Delay panic for aliasing violation for static items.

Closes #46604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants