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: assertion failed: bpos.to_usize() >= mbc.pos.to_usize() + mbc.bytes #48508

Closed
fintelia opened this issue Feb 24, 2018 · 1 comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@fintelia
Copy link
Contributor

I tried this code:

lib.rs:

#![feature(iterator_step_by)]
#![feature(ord_max_min)]
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(try_from)]
#![feature(slice_patterns)]
#![feature(non_ascii_idents)]

pub mod precompute;

precompute.rs:

#[test]
fn it_works() {
    fn inner() -> f64 {
        let µ = 1.0;
        µ
    }
    let _µ = inner();
}

I expected to see this happen: compile properly and tests pass.

Instead, this happened: internal compiler error.

Possibly related to #46773, but I wasn't sure since the backtraces seemed rather different.

Meta

rustc --version --verbose:

rustc 1.26.0-nightly (063deba92 2018-02-23)
binary: rustc
commit-hash: 063deba92e44809125a433ca6e6c1ad0993313bf
commit-date: 2018-02-23
host: x86_64-unknown-linux-gnu
release: 1.26.0-nightly
LLVM version: 6.0

Backtrace:

   Compiling unicode v0.1.0 (file:///home/jonathan/tmp/unicode)
thread 'rustc' panicked at 'assertion failed: bpos.to_usize() >= mbc.pos.to_usize() + mbc.bytes', libsyntax/codemap.rs:764:17
stack backtrace:
   0:     0x7f065582e063 - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::hd00aa766a56fe293
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f0655825554 - std::sys_common::backtrace::_print::h54da06fb16cb9ad6
                               at libstd/sys_common/backtrace.rs:71
   2:     0x7f065582ac9d - std::panicking::default_hook::{{closure}}::h67dd2c5bdfbcdba1
                               at libstd/sys_common/backtrace.rs:59
                               at libstd/panicking.rs:206
   3:     0x7f065582a999 - std::panicking::default_hook::h14daf183f7987b45
                               at libstd/panicking.rs:222
   4:     0x7f065582b0ff - std::panicking::rust_panic_with_hook::haf158391394f8248
                               at libstd/panicking.rs:400
   5:     0x7f06516247c5 - std::panicking::begin_panic::hc4b15280f4aac00e
   6:     0x7f06516ada1b - syntax::codemap::CodeMap::bytepos_to_file_charpos::h1904a2e0951f1ef0
   7:     0x7f06516aa4e4 - syntax::codemap::CodeMap::lookup_char_pos::hf465c34067aaa7fe
   8:     0x7f064aaf53f3 - rustc_trans::mir::FunctionCx::set_debug_loc::h1fab6c6c56da0887
   9:     0x7f064aafb4db - rustc_trans::mir::trans_mir::hd5460c3409d3184b
  10:     0x7f064aabd553 - rustc_trans::base::trans_instance::h7a0842c683f85f40
  11:     0x7f064aac8f4d - rustc_trans::base::compile_codegen_unit::h89925300458c236e
  12:     0x7f065241df64 - rustc::dep_graph::graph::DepGraph::with_task_impl::h8d57a8788dba82ff
  13:     0x7f06527f5b50 - rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::force::h9473f2f719c9e900
  14:     0x7f06527f6f2f - rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get::hb1acd3d0f00d8e17
  15:     0x7f0652816a4c - rustc::ty::maps::TyCtxtAt::compile_codegen_unit::h0f13d4057b5fa559
  16:     0x7f065280f5b9 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit::h57dae7b07151dfca
  17:     0x7f064aabf637 - rustc_trans::base::trans_crate::h510f789f4dd2fca5
  18:     0x7f064ab1b007 - <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate::hc34c86a7991a2357
  19:     0x7f0655be16c2 - rustc_driver::driver::phase_4_translate_to_llvm::heb37816963659b45
  20:     0x7f0655bda6ce - rustc_driver::driver::compile_input::{{closure}}::hb05e220533907e90
  21:     0x7f0655b7176e - rustc::ty::context::TyCtxt::create_and_enter::h74bf9fb47bfc54a3
  22:     0x7f0655bd867b - rustc_driver::driver::compile_input::hac1d19a7e4d66b92
  23:     0x7f0655bf575a - rustc_driver::run_compiler::h5fd8f6d44462a7b6
  24:     0x7f0655b20a8a - std::sys_common::backtrace::__rust_begin_short_backtrace::h093a629e65f72505
  25:     0x7f0655843c4e - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:102
  26:     0x7f0655b59ca6 - <F as alloc::boxed::FnBox<A>>::call_box::h41c53d796e08f220
  27:     0x7f065583b00b - std::sys::unix::thread::Thread::new::thread_start::h72150edde1f62ab4
                               at /checkout/src/liballoc/boxed.rs:798
                               at libstd/sys_common/thread.rs:24
                               at libstd/sys/unix/thread.rs:90
  28:     0x7f065070f7fb - start_thread
  29:     0x7f06554f3b5e - clone
  30:                0x0 - <unknown>
@fintelia
Copy link
Contributor Author

Slightly simpler example:

main.rs:

#![feature(non_ascii_idents)]

mod inner;
fn main() {
    inner::inner();
}

inner.rs:

pub fn foo() -> f64 {
    let µ = 1.0;
    µ
}

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 24, 2018
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 1, 2018
…-at-span-bounds-check, r=estebank

Fix find_width_of_character_at_span bounds check

Commit 0bd9667 added bounds checking of our current target byte position to prevent infinite loops. Unfortunately it was comparing the file-relative `target` versus the global `file_start_pos` and `file_end_pos`.

The result is failing to detect multibyte characters unless their file-relative offset fit within their global offset. This causes other parts of the compiler to generate spans pointing to the middle of a
multibyte character which will ultimately panic in `bytepos_to_file_charpos`.

Fix by comparing the `target` to the total file size when moving forward and doing checked subtraction when moving backwards. This should preserve the intent of the bounds check while removing the offset confusion.

cc @davidtwco

Fixes rust-lang#48508
Dylan-DPC-zz referenced this issue in Dylan-DPC-zz/rust Mar 21, 2021
…chenkov

Move some tests to more reasonable directories - 5

cc rust-lang#73494

Threshold is 0.95. Next time I promise I will take a look into the special/misclassified directories.

- [issues/issue-23208.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-23208.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/23208)</sup>: associated-types 0.951
- [weird-exprs.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/weird-exprs.rs) <sup>unknown</sup>: destructuring-assignment 0.958
- [issues/issue-1701.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-1701.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/1701)</sup>: structs-enums 0.974
- [issues/issue-48508-aux.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-48508-aux.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/48508)</sup>: numbers-arithmetic 0.991
- [fn_must_use.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/fn_must_use.rs) <sup>unknown</sup>: lint 1.000
- [mir_check_nonconst.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir_check_nonconst.rs) <sup>unknown</sup>: consts 1.002
- [issues/issue-52060.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-52060.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/52060)</sup>: consts 1.017
- [issues/issue-45729-unsafe-in-generator.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-45729-unsafe-in-generator.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/45729)</sup>: generator 1.024
- [issues/issue-10392.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-10392.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/10392)</sup>: pattern 1.039
- [no-implicit-prelude.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/no-implicit-prelude.rs) <sup>unknown</sup>: resolve 1.071
- [issues/issue-68000-unicode-ident-after-missing-comma.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/68000)</sup>: parser 1.079
- [shadow.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/shadow.rs) <sup>unknown</sup>: binding 1.099
- [issues/issue-65611.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-65611.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/65611)</sup>: consts 1.139
- [concat-rpass.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/concat-rpass.rs) <sup>unknown</sup>: macros 1.194
- [issues/issue-31597.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-31597.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/31597)</sup>: associated-types 1.195
- [issues/issue-78372.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-78372.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/78372)</sup>: resolve 1.426
- [impl-trait-in-bindings-issue-73003.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings-issue-73003.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/73003)</sup>: impl-trait 1.471
- [impl-trait-in-bindings.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings.rs) <sup>unknown</sup>: impl-trait 2.500

r? `@petrochenkov`
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

2 participants