Skip to content

Compiler panics after restructuring of project: attempted .def_id() on invalid def: PrimTy(Float(f64)) #60976

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
smukherjee2016 opened this issue May 20, 2019 · 6 comments · Fixed by #68485
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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.

Comments

@smukherjee2016
Copy link

smukherjee2016 commented May 20, 2019

Hello,

I was working on my toy project here:
https://github.com/smukherjee2016/sayo_pbr_rs

The project was compiling and running fine at this commit:
smukherjee2016/sayo_pbr_rs@e8f071c

However, I decided I wanted to move functionality out of src/lib.rs and into src/scene/mod.rs, so I moved all of it except the mod declarations, and then tried to compile. This led to the compiler panic.

The repro commit for this:
smukherjee2016/sayo_pbr_rs@ecf225f

I am using CLion, and the command I run is simply cargo run.

I am pretty new to Rust so it might just be me doing something really wrong, but it'd be great if someone could look into this and advise. Thank you!

With stable-msvc:

C:/Users/aaa/.cargo/bin/cargo.exe run --color=always --verbose
       Fresh autocfg v0.1.2
       Fresh rand_core v0.4.0
       Fresh lazy_static v1.3.0
       Fresh ucd-util v0.1.3
       Fresh cfg-if v0.1.7
       Fresh utf8-ranges v1.0.2
       Fresh glob v0.3.0
       Fresh tobj v0.1.7
       Fresh rand_core v0.3.1
       Fresh winapi v0.3.7
       Fresh thread_local v0.3.6
       Fresh regex-syntax v0.6.6
       Fresh log v0.4.6
       Fresh num-traits v0.2.6
       Fresh memchr v2.2.0
       Fresh libc v0.2.54
       Fresh rand_os v0.1.3
       Fresh rand_isaac v0.1.1
       Fresh rand_jitter v0.1.4
       Fresh rand_xorshift v0.1.1
       Fresh rand_hc v0.1.0
       Fresh num-integer v0.1.39
       Fresh aho-corasick v0.7.3
       Fresh serde v1.0.90
       Fresh approx v0.3.2
       Fresh byteorder v1.3.1
       Fresh rand_chacha v0.1.1
       Fresh time v0.1.42
       Fresh rand_pcg v0.1.2
       Fresh chrono v0.4.6
       Fresh rand v0.6.5
       Fresh regex v1.1.6
       Fresh toml v0.5.0
       Fresh cgmath v0.17.0
       Fresh flexi_logger v0.11.4
   Compiling sayo_pbr_rs v0.1.0 (D:\Projects\sayo_pbr_rs)
     Running `rustc --edition=2018 --crate-name sayo_pbr_rs src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=3ffc7db9e0761e27 -C extra-filename=-3ffc7db9e0761e27 --out-dir D:\Projects\sayo_pbr_rs\target\debug\deps -C incremental=D:\Projects\sayo_pbr_rs\target\debug\incremental -L dependency=D:\Projects\sayo_pbr_rs\target\debug\deps --extern byteorder=D:\Projects\sayo_pbr_rs\target\debug\deps\libbyteorder-e8f2bbdead8ba3f8.rlib --extern cgmath=D:\Projects\sayo_pbr_rs\target\debug\deps\libcgmath-2798cd25d5fd5062.rlib --extern flexi_logger=D:\Projects\sayo_pbr_rs\target\debug\deps\libflexi_logger-2b2774cc44427bf5.rlib --extern log=D:\Projects\sayo_pbr_rs\target\debug\deps\liblog-6012325b2cce08de.rlib --extern sayo_pbr_rs=D:\Projects\sayo_pbr_rs\target\debug\deps\libsayo_pbr_rs-5f4f51f2f3ce30dc.rlib --extern tobj=D:\Projects\sayo_pbr_rs\target\debug\deps\libtobj-10b58215fa882cc1.rlib --extern toml=D:\Projects\sayo_pbr_rs\target\debug\deps\libtoml-d1b47d405b8aaba4.rlib`
error: internal compiler error: src\librustc\hir\def.rs:259: attempted .def_id() on invalid def: PrimTy(Float(f64))

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:620:9
stack backtrace:
   0: std::sys_common::alloc::realloc_fallback
   1: std::panicking::take_hook
   2: std::panicking::take_hook
   3: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
   4: std::panicking::rust_panic_with_hook
   5: <rustc_errors::emitter::ColorConfig as core::fmt::Debug>::fmt
   6: rustc_errors::Handler::bug
   7: rustc::util::bug::bug_fmt
   8: rustc::ty::wf::object_region_bounds
   9: rustc::ty::wf::object_region_bounds
  10: rustc::ty::wf::object_region_bounds
  11: rustc::util::bug::bug_fmt
  12: rustc::util::bug::bug_fmt
  13: rustc::hir::def::Def::def_id
  14: rustc::hir::def::Def::def_id
  15: rustc_metadata::cstore::CStore::new
  16: rustc::middle::weak_lang_items::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'gcx>>::is_weak_lang_item
  17: rustc::dep_graph::graph::DepGraph::assert_ignored
  18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  19: rustc::ty::item_path::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::absolute_item_path_str
  20: rustc::util::ppaux::PrintContext::new
  21: rustc::util::ppaux::<impl core::fmt::Debug for rustc::ty::sty::TraitRef<'tcx>>::fmt
  22: rustc::util::ppaux::<impl core::fmt::Display for rustc::ty::TyS<'tcx>>::fmt
  23: core::fmt::write
  24: alloc::fmt::format
  25: <rustc_lint::builtin::WhileTrue as rustc::lint::LateLintPass<'a, 'tcx>>::check_expr
  26: <rustc_lint::register_builtins::BuiltinCombinedLateLintPass as rustc::lint::LateLintPass<'a, 'tcx>>::check_expr
  27: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  28: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
  29: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
  30: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn
  31: rustc::hir::intravisit::NestedVisitorMap::inter
  32: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  33: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  34: rustc::hir::intravisit::NestedVisitorMap::inter
  35: rustc::lint::context::check_crate
  36: rustc_driver::profile::dump
  37: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  38: <env_logger::fmt::WriteStyle as core::default::Default>::default
  39: rustc_driver::driver::compile_input
  40: rustc_driver::run_compiler
  41: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  42: rustc_driver::run_compiler
  43: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  44: _rust_maybe_catch_panic
  45: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  46: std::sys::windows::thread::Thread::new
  47: BaseThreadInitThunk
  48: RtlUserThreadStart
query stack during panic:
#0 [visible_parent_map] calculating the visible parent map
end of query stack
error: aborting due to previous error


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.34.2 (6c2484dc3 2019-05-13) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `sayo_pbr_rs`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name sayo_pbr_rs src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=3ffc7db9e0761e27 -C extra-filename=-3ffc7db9e0761e27 --out-dir D:\Projects\sayo_pbr_rs\target\debug\deps -C incremental=D:\Projects\sayo_pbr_rs\target\debug\incremental -L dependency=D:\Projects\sayo_pbr_rs\target\debug\deps --extern byteorder=D:\Projects\sayo_pbr_rs\target\debug\deps\libbyteorder-e8f2bbdead8ba3f8.rlib --extern cgmath=D:\Projects\sayo_pbr_rs\target\debug\deps\libcgmath-2798cd25d5fd5062.rlib --extern flexi_logger=D:\Projects\sayo_pbr_rs\target\debug\deps\libflexi_logger-2b2774cc44427bf5.rlib --extern log=D:\Projects\sayo_pbr_rs\target\debug\deps\liblog-6012325b2cce08de.rlib --extern sayo_pbr_rs=D:\Projects\sayo_pbr_rs\target\debug\deps\libsayo_pbr_rs-5f4f51f2f3ce30dc.rlib --extern tobj=D:\Projects\sayo_pbr_rs\target\debug\deps\libtobj-10b58215fa882cc1.rlib --extern toml=D:\Projects\sayo_pbr_rs\target\debug\deps\libtoml-d1b47d405b8aaba4.rlib` (exit code: 101)

Process finished with exit code 101

With stable-gnu:

C:/Users/aaa/.cargo/bin/cargo.exe run --color=always --verbose
       Fresh autocfg v0.1.2
       Fresh rand_core v0.4.0
       Fresh lazy_static v1.3.0
       Fresh ucd-util v0.1.3
       Fresh utf8-ranges v1.0.2
       Fresh cfg-if v0.1.7
       Fresh glob v0.3.0
       Fresh tobj v0.1.7
       Fresh winapi-x86_64-pc-windows-gnu v0.4.0
       Fresh rand_core v0.3.1
       Fresh regex-syntax v0.6.6
       Fresh thread_local v0.3.6
       Fresh log v0.4.6
       Fresh memchr v2.2.0
       Fresh winapi v0.3.7
       Fresh libc v0.2.54
       Fresh num-traits v0.2.6
       Fresh rand_xorshift v0.1.1
       Fresh aho-corasick v0.7.3
       Fresh rand_hc v0.1.0
       Fresh rand_isaac v0.1.1
       Fresh rand_pcg v0.1.2
       Fresh serde v1.0.90
       Fresh byteorder v1.3.1
       Fresh rand_jitter v0.1.4
       Fresh time v0.1.42
       Fresh num-integer v0.1.39
       Fresh rand_os v0.1.3
       Fresh approx v0.3.2
       Fresh rand_chacha v0.1.1
       Fresh chrono v0.4.6
       Fresh regex v1.1.6
       Fresh toml v0.5.0
       Fresh rand v0.6.5
       Fresh flexi_logger v0.11.4
       Fresh cgmath v0.17.0
   Compiling sayo_pbr_rs v0.1.0 (D:\Projects\sayo_pbr_rs)
     Running `rustc --edition=2018 --crate-name sayo_pbr_rs src\lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=3e12efdc8c5b8afd -C extra-filename=-3e12efdc8c5b8afd --out-dir D:\Projects\sayo_pbr_rs\target\debug\deps -C incremental=D:\Projects\sayo_pbr_rs\target\debug\incremental -L dependency=D:\Projects\sayo_pbr_rs\target\debug\deps --extern byteorder=D:\Projects\sayo_pbr_rs\target\debug\deps\libbyteorder-1c9417ab32935f79.rlib --extern cgmath=D:\Projects\sayo_pbr_rs\target\debug\deps\libcgmath-fde0a6dc7fd6e47e.rlib --extern flexi_logger=D:\Projects\sayo_pbr_rs\target\debug\deps\libflexi_logger-13585d6e89f99240.rlib --extern log=D:\Projects\sayo_pbr_rs\target\debug\deps\liblog-102d34c518e2a691.rlib --extern tobj=D:\Projects\sayo_pbr_rs\target\debug\deps\libtobj-ddb5172681a9ec8a.rlib --extern toml=D:\Projects\sayo_pbr_rs\target\debug\deps\libtoml-099e41e0be53e63b.rlib -L native=C:\Users\Subham\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib`
warning: unused variable: `materials`
  --> src\geometry\triangle.rs:28:22
   |
28 |         let (models, materials) = obj_mesh.unwrap();
   |                      ^^^^^^^^^ help: consider prefixing with an underscore: `_materials`

warning: unused variable: `ray`
  --> src\geometry\triangle.rs:77:57
   |
77 |     fn check_intersection_and_return_closest_hit(&self, ray: Ray) -> Option<IntersectionInfo> {
   |                                                         ^^^ help: consider prefixing with an underscore: `_ray`

     Running `rustc --edition=2018 --crate-name sayo_pbr_rs src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=f2bb5465dd356841 -C extra-filename=-f2bb5465dd356841 --out-dir D:\Projects\sayo_pbr_rs\target\debug\deps -C incremental=D:\Projects\sayo_pbr_rs\target\debug\incremental -L dependency=D:\Projects\sayo_pbr_rs\target\debug\deps --extern byteorder=D:\Projects\sayo_pbr_rs\target\debug\deps\libbyteorder-1c9417ab32935f79.rlib --extern cgmath=D:\Projects\sayo_pbr_rs\target\debug\deps\libcgmath-fde0a6dc7fd6e47e.rlib --extern flexi_logger=D:\Projects\sayo_pbr_rs\target\debug\deps\libflexi_logger-13585d6e89f99240.rlib --extern log=D:\Projects\sayo_pbr_rs\target\debug\deps\liblog-102d34c518e2a691.rlib --extern sayo_pbr_rs=D:\Projects\sayo_pbr_rs\target\debug\deps\libsayo_pbr_rs-3e12efdc8c5b8afd.rlib --extern tobj=D:\Projects\sayo_pbr_rs\target\debug\deps\libtobj-ddb5172681a9ec8a.rlib --extern toml=D:\Projects\sayo_pbr_rs\target\debug\deps\libtoml-099e41e0be53e63b.rlib -L native=C:\Users\Subham\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib`
error: internal compiler error: src\librustc\hir\def.rs:259: attempted .def_id() on invalid def: PrimTy(Float(f64))

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:620:9
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
  36: mingw_set_invalid_parameter_handler
  37: mingw_set_invalid_parameter_handler
  38: mingw_set_invalid_parameter_handler
  39: mingw_set_invalid_parameter_handler
  40: mingw_set_invalid_parameter_handler
  41: mingw_set_invalid_parameter_handler
  42: mingw_set_invalid_parameter_handler
  43: mingw_set_invalid_parameter_handler
  44: mingw_set_invalid_parameter_handler
  45: mingw_set_invalid_parameter_handler
  46: mingw_set_invalid_parameter_handler
  47: mingw_set_invalid_parameter_handler
  48: mingw_set_invalid_parameter_handler
query stack during panic:
#0 [visible_parent_map] calculating the visible parent map
end of query stack
error: aborting due to previous error


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.34.1 (fc50f328b 2019-04-24) running on x86_64-pc-windows-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `sayo_pbr_rs`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name sayo_pbr_rs src\main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=f2bb5465dd356841 -C extra-filename=-f2bb5465dd356841 --out-dir D:\Projects\sayo_pbr_rs\target\debug\deps -C incremental=D:\Projects\sayo_pbr_rs\target\debug\incremental -L dependency=D:\Projects\sayo_pbr_rs\target\debug\deps --extern byteorder=D:\Projects\sayo_pbr_rs\target\debug\deps\libbyteorder-1c9417ab32935f79.rlib --extern cgmath=D:\Projects\sayo_pbr_rs\target\debug\deps\libcgmath-fde0a6dc7fd6e47e.rlib --extern flexi_logger=D:\Projects\sayo_pbr_rs\target\debug\deps\libflexi_logger-13585d6e89f99240.rlib --extern log=D:\Projects\sayo_pbr_rs\target\debug\deps\liblog-102d34c518e2a691.rlib --extern sayo_pbr_rs=D:\Projects\sayo_pbr_rs\target\debug\deps\libsayo_pbr_rs-3e12efdc8c5b8afd.rlib --extern tobj=D:\Projects\sayo_pbr_rs\target\debug\deps\libtobj-ddb5172681a9ec8a.rlib --extern toml=D:\Projects\sayo_pbr_rs\target\debug\deps\libtoml-099e41e0be53e63b.rlib -L native=C:\Users\Subham\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib` (exit code: 101)

Process finished with exit code 101

EDIT: Updated with last working commit.
EDIT2: Posted crash message with --verbose flag and clarified IDE.
EDIT3: Added MSVC toolchain error.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 20, 2019
@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 21, 2019
@estebank
Copy link
Contributor

I have a PR that will fix the underlying problem, but we need to come up with a reproduction case to avoid regressions in the future.

@jonas-schievink
Copy link
Contributor

Removing nomination since a fix is already approved

Centril added a commit to Centril/rust that referenced this issue May 21, 2019
Do not fail on child without DefId

Addresses rust-lang#60976, leaving open to come up with a repro case.
Centril added a commit to Centril/rust that referenced this issue May 21, 2019
Do not fail on child without DefId

Addresses rust-lang#60976, leaving open to come up with a repro case.
Centril added a commit to Centril/rust that referenced this issue May 22, 2019
Do not fail on child without DefId

Addresses rust-lang#60976, leaving open to come up with a repro case.
Centril added a commit to Centril/rust that referenced this issue May 22, 2019
Do not fail on child without DefId

Addresses rust-lang#60976, leaving open to come up with a repro case.
@smukherjee2016
Copy link
Author

Thank you so much for the super-fast response! However, I am not at all familiar with rust's compiler code, so if you could tell which part of the code the compiler trips upon, I can try isolating that part of the code to make a smaller reproducible example.

@hellow554
Copy link
Contributor

hellow554 commented Aug 5, 2019

Reduced it down to two files:

src/main.rs: (replace enter_crate_name_here obvisouly ^^)

use \enter_crate_name_here\;

fn main() {}

src/lib.rs:

pub use u32;

u32 can be any primtive type as u8, usize, i32, f64. Haven't managed to get it down to one file sadly :/

@Centril Centril added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Oct 25, 2019
@kingslef
Copy link
Contributor

is there a problem of adding the test in two files (with aux-build)? if not, I could try to work on this as a first issue.

@jonas-schievink
Copy link
Contributor

@kingslef No, that's totally fine. Go for it!

kingslef added a commit to kingslef/rust that referenced this issue Jan 23, 2020
The test fails on 1.36.0 but passes on master.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jan 25, 2020
…akis

add a test for rust-lang#60976

The test fails on 1.36.0 but passes on master.

Huge thanks for @hellow554 actually digging out the minimized version of the
repro.

Fixes rust-lang#60976.
bors added a commit that referenced this issue Jan 25, 2020
Rollup of 5 pull requests

Successful merges:

 - #68485 (add a test for #60976)
 - #68498 (Add some type-alias-impl-trait regression tests)
 - #68514 (Use Self instead of self return type)
 - #68534 (Update submodules to rust-lang)
 - #68540 (clean up error codes E0229 and E0261)

Failed merges:

r? @ghost
@bors bors closed this as completed in 88429fb Jan 26, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants