rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.98k stars 12.68k forks source link

error: internal compiler error: encountered incremental compilation error with predicates_of(bitpacking[28cc]::BitPacker) #86476

Closed rana closed 1 year ago

rana commented 3 years ago

Code

Ran the fn num_bits_pkg() from VSCode "Run test"


#[cfg(test)]
mod test {
  extern crate bitpacking;
  use bitpacking::{BitPacker, BitPacker8x};
  use core_simd::*;

  #[test]
  fn delta() {
    let a = u32x4::splat(10);
    let b = u32x4::from_array([1, 2, 3, 4]);
    println!("{:?}", a + b);
  }

  #[test]
  fn hello_simd_u32() {
    let a = u32x4::splat(10);
    let b = u32x4::from_array([1, 2, 3, 4]);
    println!("{:?}", a + b);
  }

  #[test]
  fn hello_simd() {
    let a = f32x4::splat(10.0);
    let b = f32x4::from_array([1.0, 2.0, 3.0, 4.0]);
    println!("{:?}", a + b);
  }

  #[test]
  fn num_bits_pkg() {
    let src = blk();
    let bitpacker = BitPacker8x::new();
    let initial_value = 0u32;
    let num_bits_sorted: u8 = bitpacker.num_bits_sorted(src[0], &src);
    println!("num_bits_sorted {}", num_bits_sorted);
  }

  fn blk() -> Vec<u32> {
    // first 256 goog timestamps
    // sorted ascending u32
    return vec![
      509, 610, 711, 1096, 1147, 2019, 2069, 2124, 2445, 2495, 2635, 2686, 2789, 3570, 3621, 4616,
      4668, 5120, 5171, 5221, 5531, 6025, 9047, 9265, 9496, 9547, 9905, 10203, 11091, 11379, 12156,
      12257, 12372, 12487, 12596, 12646, 12697, 13094, 13580, 13630, 13781, 14458, 14508, 14713,
      14763, 14831, 15270, 15381, 15527, 15683, 15784, 15934, 17160, 17211, 17261, 17392, 17584,
      17690, 17791, 17900, 18094, 18685, 20052, 20324, 20375, 25580, 26979, 27286, 28619, 28669,
      30662, 31585, 31635, 32337, 33434, 34933, 35051, 35176, 35277, 35423, 35577, 35728, 35871,
      36055, 36105, 36960, 37074, 37200, 37347, 37475, 37593, 37724, 37873, 37923, 37974, 38024,
      38075, 38211, 39060, 43483, 43533, 45739, 47901, 48028, 48226, 48361, 50448, 50651, 50786,
      50936, 51054, 51238, 51486, 51656, 51839, 51941, 51991, 52042, 52144, 52247, 52349, 52453,
      53551, 53601, 55059, 55110, 55196, 55720, 57773, 58271, 58383, 58487, 58588, 58727, 58777,
      59093, 59143, 60587, 60834, 61239, 61971, 63395, 63445, 63546, 63687, 65027, 65491, 66139,
      66610, 71431, 71541, 71654, 71758, 71859, 71963, 72013, 72063, 72164, 72536, 72657, 72847,
      72948, 73422, 73954, 74124, 74225, 74325, 74535, 74635, 74723, 74830, 74880, 74930, 74981,
      75031, 75178, 75329, 75458, 75559, 75641, 75821, 76116, 76166, 76927, 77133, 77184, 77700,
      77838, 77944, 78095, 78205, 78306, 78488, 78589, 78700, 78801, 78913, 79044, 79094, 79206,
      79307, 79408, 79522, 79658, 79794, 79944, 80047, 80201, 80302, 80410, 80511, 80703, 80804,
      80937, 81850, 81900, 82120, 82221, 82736, 82787, 82837, 82887, 82950, 83051, 83153, 83203,
      83263, 85183, 85284, 85412, 85584, 85634, 85700, 86615, 86720, 86866, 86966, 87017, 87214,
      87334, 87511, 87615, 88706, 88807, 89535, 89585, 89703, 90132, 90538, 90639, 90747, 90942,
      91093, 91194, 91338, 91448,
    ];
  }
}

Meta

rustc --version --verbose:

rana@aum:~/prj/tsr$ rustc --version --verbose
rustc 1.55.0-nightly (539d7bd39 2021-06-14)
binary: rustc
commit-hash: 539d7bd3998d9bfed14c264eacda30097a4ea768
commit-date: 2021-06-14
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

> Executing task: cargo test -- --nocapture num_bits_pkg <

   Compiling tsr v0.1.0 (/home/rana/prj/tsr)
error: internal compiler error: encountered incremental compilation error with predicates_of(bitpacking[28cc]::BitPacker)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p tsr` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information

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.55.0-nightly (539d7bd39 2021-06-14) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [predicates_of] computing predicates of `pck::test::bitpacking::BitPacker`
#1 [typeck] type-checking `pck::test::num_bits_pkg`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `tsr`

To learn more, run the command again with --verbose.
The terminal process "bash '-c', 'cargo test -- --nocapture num_bits_pkg'" terminated with exit code: 101.

Terminal will be reused by tasks, press any key to close it.
Backtrace

``` thread 'rustc' panicked at 'Found unstable fingerprints for predicates_of(bitpacking[28cc]::BitPacker): GenericPredicates { parent: None, predicates: [(Binder(TraitPredicate(), []), /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs:162:22: 162:27 (#0)), (Binder(TraitPredicate(), []), /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs:162:30: 162:35 (#0)), (Binder(TraitPredicate(), []), /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs:162:38: 162:42 (#0)), (Binder(TraitPredicate(), []), /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs:162:1: 263:2 (#0))] }', /rustc/539d7bd3998d9bfed14c264eacda30097a4ea768/compiler/rustc_query_system/src/query/plumbing.rs:620:9 stack backtrace: 0: rust_begin_unwind at /rustc/539d7bd3998d9bfed14c264eacda30097a4ea768/library/std/src/panicking.rs:515:5 1: std::panicking::begin_panic_fmt at /rustc/539d7bd3998d9bfed14c264eacda30097a4ea768/library/std/src/panicking.rs:457:5 2: rustc_query_system::query::plumbing::incremental_verify_ich 3: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory 4: rustc_data_structures::stack::ensure_sufficient_stack 5: rustc_query_system::query::plumbing::get_query_impl 6: ::predicates_of 7: rustc_middle::ty::generics::GenericPredicates::instantiate_into 8: rustc_middle::ty::generics::GenericPredicates::instantiate 9: rustc_typeck::check::fn_ctxt::_impl::::instantiate_bounds 10: rustc_typeck::check::fn_ctxt::_impl::::add_required_obligations 11: rustc_typeck::check::fn_ctxt::_impl::::instantiate_value_path 12: rustc_typeck::check::expr::::check_expr_kind 13: rustc_typeck::check::expr::::check_expr_with_expectation 14: rustc_typeck::check::callee::::check_call 15: rustc_typeck::check::expr::::check_expr_kind 16: rustc_typeck::check::expr::::check_expr_with_expectation 17: rustc_typeck::check::fn_ctxt::checks::::check_decl_initializer 18: rustc_typeck::check::fn_ctxt::checks::::check_decl_local 19: rustc_typeck::check::fn_ctxt::checks::::check_stmt 20: rustc_typeck::check::fn_ctxt::checks::::check_block_with_expected 21: rustc_typeck::check::expr::::check_expr_with_expectation 22: rustc_typeck::check::expr::::check_return_expr 23: rustc_typeck::check::check::check_fn 24: rustc_typeck::check::inherited::InheritedBuilder::enter 25: rustc_typeck::check::typeck 26: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 27: rustc_data_structures::stack::ensure_sufficient_stack 28: rustc_query_system::query::plumbing::force_query_with_job 29: rustc_query_system::query::plumbing::get_query_impl 30: ::typeck 31: rustc_middle::ty::::par_body_owners 32: rustc_typeck::check::typeck_item_bodies 33: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 34: rustc_data_structures::stack::ensure_sufficient_stack 35: rustc_query_system::query::plumbing::force_query_with_job 36: rustc_query_system::query::plumbing::get_query_impl 37: ::typeck_item_bodies 38: rustc_session::utils::::time 39: rustc_typeck::check_crate 40: rustc_interface::passes::analysis 41: rustc_middle::dep_graph::::with_deps 42: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 43: rustc_query_system::dep_graph::graph::DepGraph::with_eval_always_task 44: rustc_data_structures::stack::ensure_sufficient_stack 45: rustc_query_system::query::plumbing::force_query_with_job 46: rustc_query_system::query::plumbing::get_query_impl 47: ::analysis 48: rustc_interface::queries::::enter 49: rustc_span::with_source_map 50: rustc_interface::interface::create_compiler_and_run 51: scoped_tls::ScopedKey::set note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. ```

Aaron1011 commented 3 years ago

@rana: Could you share your Cargo.toml (and ideally, the entire repository)?

rana commented 3 years ago

Hi Aaron,

Great to hear from you. You're fast :slightly_smiling_face:

Attached is the project that generated the bug.

Most of it is hello_world-level stuff- and disconnected tinkering.

The workflow was to run a test, write some code, run a test.

By about the second or third test-change the defect was consistent to get.

Hope that helps, and let me know if you have any questions.

Cheers!

Rana Ian

tsr.zip

Aaron1011 commented 3 years ago

@rana: Unfortunately, I'm not able to reproduce your crash locally. Could you elaborate on the kinds if changes you were making to the tests before the crash started occuring?

rana commented 3 years ago

@Aaron1011 I'm not able to reproduce it here again as well. If I see it again I'll do a screen record and post it.

Aaron1011 commented 3 years ago

The last predicate listed in the error message is interesting: Binder(TraitPredicate(<Self as pck::test::bitpacking::BitPacker>), []), /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs:162:1: 263:2 (#0))

It appears to be generated here:

https://github.com/rust-lang/rust/blob/f639657fe4a16ec7704e0af77d0e5d5f587b59df/compiler/rustc_typeck/src/collect.rs#L1919-L1924

The fact that we call guess_head_span means that the span should be a single line (containing pub trait BitPacker: Sized + Clone + Copy). However, the span is for the entire definition of the BitPacker trait, indicating that guess_head_span failed.

The file in question is part of a dependency, so it shouldn't have changed between compilation sessions (if the version number changed, then we would be dealing with a different file, since the version number is included in the directory name bitpacking-0.8.4). I suspect that there's a bug in some of the filesystem-loading code involved in guess_head_span - I'll investigate further.

Aaron1011 commented 3 years ago

I've managed to create a predicates_of ICE locally by changing a file in a dependency, without modifying the timestamp. When Rust tries to read in an 'external src file' from the dependency during the second compilation session, the src_hash will no longer match. This causes span_to_snippet to fail, causing us to generate a different span in predicates_of.

However, I'm not sure if this is the same ICE that you've reported. @rana: Is there any change that /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs somehow got modified between compilation sessions? Is /home/rana/.cargo on an atypical partition (e.g. NFS)?

EDIT: On further investigation, it appears that modifying files in ~/.cargo/registry does not trigger a rebuild of the dependency, even though the modification time changes. I think a modification of bitpacking-0.8.4/src/lib.rs, combined with certain modifications to the tsr crate, would be enough to cause an ICE similar to the one that you're seeing.

rana commented 3 years ago

No change to /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs. That's stable. I don't edit it.

/home/rana/.cargo is on an ordinary partition as well. Here is the output from lsblk.

rana@aum:~$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 238.5G  0 disk 
└─sda1        8:1    0 238.5G  0 part 
sr0          11:0    1  1024M  0 rom  
nvme0n1     259:0    0   1.1T  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
└─nvme0n1p2 259:2    0   1.1T  0 part /

The workflow was only to add new tests, and use the in-IDE "Run test" link shown in the snapshot.

image

The current output window command (that's currently working) shows:

> Executing task: cargo test -- --nocapture num_bits_pkg <

    Finished test [unoptimized + debuginfo] target(s) in 0.09s
     Running unittests (target/debug/deps/tsr-6150d47f1fc41f28)

running 3 tests
num_bits_sorted 13
num_bits_sorted 13
num_bits_sorted 13
test pck::test::num_bits_pkg_2 ... ok
test pck::test::num_bits_pkg_3 ... ok
test pck::test::num_bits_pkg ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out; finished in 0.00s

When I get back to that workflow of adding new tests and code I expect it to crash as consistently as it did before. But I also plan to stop using nightly because of it.

Aaron1011 commented 3 years ago

That's interesting. The fact that you were getting the ICE consistently would seem to rule out any kind of transient I/O issue - Rust would need to fail to open /home/rana/.cargo/registry/src/github.com-1ecc6299db9ec823/bitpacking-0.8.4/src/lib.rs each time you got the ICE.

I've opened https://github.com/rust-lang/rust/issues/86480 to track an issue that I've discovered from investigation this. It's possible that these two issues are actually the same, but I'm not certain.

Enselic commented 1 year ago

Triage: Thank you for reporting. Since there is no way for others to reproduce the ICE reported in this issue, let's assume it is a duplicate. Feel free to reopen this issue if it turns out it is not a duplicate and after figuring out how others can reproduce this ICE.