Skip to content

Unexpected Panic when compiling static objects #19380

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

Closed
IdeaHat opened this issue Nov 28, 2014 · 2 comments
Closed

Unexpected Panic when compiling static objects #19380

IdeaHat opened this issue Nov 28, 2014 · 2 comments
Labels
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) ❄️

Comments

@IdeaHat
Copy link

IdeaHat commented Nov 28, 2014

I'm getting a crash when trying to compiler a bunch of const objects, not sure why.

Sounce code:
https://github.com/IdeaHat/servo/
Branch: staticifying
Commit: 52308c1f01f172caacd4a71a04e0bc519824eba2
Compiliation Instructions:
./mach build
./mach rustc --test ./components/net/mime_classifier.rs

components/net/mime_classifier.rs:349:52: 349:55 warning: path statement with no effect, #[warn(path_statements)] on by default
components/net/mime_classifier.rs:349                                  if tp.is_some() { tp;}
                                                                                         ^~~
components/net/mime_classifier.rs:779:1: 792:3 warning: constant item is never used: `APPLICATION_VND_MS_FONT_OBJECT`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:779 const APPLICATION_VND_MS_FONT_OBJECT : ByteMatcher = ByteMatcher {
components/net/mime_classifier.rs:780     pattern:  [0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8,
components/net/mime_classifier.rs:781         0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8,
components/net/mime_classifier.rs:782         0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8,
components/net/mime_classifier.rs:783         0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8, 0x00u8,
components/net/mime_classifier.rs:784         0x00u8, 0x00u8, 0x4Cu8, 0x50u8],
                                      ...
components/net/mime_classifier.rs:795:1: 800:3 warning: constant item is never used: `TRUE_TYPE`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:795 const TRUE_TYPE : ByteMatcher = ByteMatcher {
components/net/mime_classifier.rs:796     pattern: [0x00u8, 0x01u8, 0x00u8, 0x00u8],
components/net/mime_classifier.rs:797     mask: [0xFFu8, 0xFFu8, 0xFFu8, 0xFFu8],
components/net/mime_classifier.rs:798     content_type: ("(TrueType)",""),
components/net/mime_classifier.rs:799     leading_ignore: []
components/net/mime_classifier.rs:800 };
components/net/mime_classifier.rs:803:1: 808:3 warning: constant item is never used: `OPEN_TYPE`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:803 const OPEN_TYPE : ByteMatcher = ByteMatcher {
components/net/mime_classifier.rs:804     pattern: [0x4Fu8, 0x54u8, 0x54u8, 0x4Fu8],
components/net/mime_classifier.rs:805     mask: [0xFFu8, 0xFFu8, 0xFFu8, 0xFFu8],
components/net/mime_classifier.rs:806     content_type: ("(OpenType)",""),
components/net/mime_classifier.rs:807     leading_ignore: []
components/net/mime_classifier.rs:808 };
components/net/mime_classifier.rs:810:1: 815:3 warning: constant item is never used: `TRUE_TYPE_COLLECTION`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:810 const TRUE_TYPE_COLLECTION : ByteMatcher = ByteMatcher {
components/net/mime_classifier.rs:811     pattern: [0x74u8, 0x74u8, 0x63u8, 0x66u8],
components/net/mime_classifier.rs:812     mask: [0xFFu8, 0xFFu8, 0xFFu8, 0xFFu8],
components/net/mime_classifier.rs:813     content_type: ("(TrueType Collection)",""),
components/net/mime_classifier.rs:814     leading_ignore: []
components/net/mime_classifier.rs:815 };
components/net/mime_classifier.rs:818:1: 823:3 warning: constant item is never used: `APPLICATION_FONT_WOFF`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:818 const APPLICATION_FONT_WOFF : ByteMatcher = ByteMatcher {
components/net/mime_classifier.rs:819     pattern: [0x77u8, 0x4Fu8, 0x46u8, 0x46u8],
components/net/mime_classifier.rs:820     mask: [0xFFu8, 0xFFu8, 0xFFu8, 0xFFu8],
components/net/mime_classifier.rs:821     content_type: ("application","font-woff"),
components/net/mime_classifier.rs:822     leading_ignore: []
components/net/mime_classifier.rs:823 };
components/net/mime_classifier.rs:965:1: 973:3 warning: constant item is never used: `FONT_CLASSIFIER`, #[warn(dead_code)] on by default
components/net/mime_classifier.rs:965 const FONT_CLASSIFIER : GroupedClassifier = GroupedClassifier {
components/net/mime_classifier.rs:966     matchers: &[
components/net/mime_classifier.rs:967       &APPLICATION_FONT_WOFF,
components/net/mime_classifier.rs:968       &TRUE_TYPE_COLLECTION,
components/net/mime_classifier.rs:969       &OPEN_TYPE,
components/net/mime_classifier.rs:970       &TRUE_TYPE,
                                      ...
components/net/mime_classifier.rs:980:9: 980:30 warning: unused import, #[warn(unused_imports)] on by default
components/net/mime_classifier.rs:980     use super::MIMEClassifier;
                                              ^~~~~~~~~~~~~~~~~~~~~
components/net/mime_classifier.rs:883:7: 883:20 error: internal compiler error: unimplemented type in const unsize: ByteMatcher
components/net/mime_classifier.rs:883       &IMAGE_X_ICON,
                                            ^~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'Box<Any>', /home/larsberg/rust/src/libsyntax/diagnostic.rs:116

stack backtrace:
   1:     0x7faa03b8e810 - rt::backtrace::imp::write::h51da061815fd4fecscq
   2:     0x7faa03b91890 - failure::on_fail::h574424058645b8db3xq
   3:     0x7faa080cb1b0 - unwind::begin_unwind_inner::h0e863b3f5b6ff01e7Rd
   4:     0x7faa04d465e0 - unwind::begin_unwind::h17623318924066054232
   5:     0x7faa04d46560 - diagnostic::SpanHandler::span_bug::h6b5bb3dcbe506a53H6F
   6:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
   7:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
   8:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
   9:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
  10:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
  11:     0x7faa08b106e0 - middle::trans::consts::const_expr_unadjusted::closure.126339
  12:     0x7faa08b0f400 - middle::trans::expr::with_field_tys::h4176170177473143547
  13:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
  14:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
  15:     0x7faa08a85410 - middle::trans::base::get_item_val::hb5c95cce53ad1c32TGi
  16:     0x7faa08b0abc0 - middle::trans::consts::get_const_val::hbdc13f3d5e74a915wvb
  17:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
  18:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
  19:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
  20:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
  21:     0x7faa08b106e0 - middle::trans::consts::const_expr_unadjusted::closure.126339
  22:     0x7faa08b0f400 - middle::trans::expr::with_field_tys::h4176170177473143547
  23:     0x7faa08b0af50 - middle::trans::consts::const_expr_unadjusted::h8d313c26ba6568f6LJb
  24:     0x7faa08b097f0 - middle::trans::consts::const_expr::h24471e6fd8e1d3e6Kwb
  25:     0x7faa08a85410 - middle::trans::base::get_item_val::hb5c95cce53ad1c32TGi
  26:     0x7faa08ad46b0 - middle::trans::expr::trans_def::hd1e848679c813cf2ft6
  27:     0x7faa08acbce0 - middle::trans::expr::trans_unadjusted::h23078de2d39048ed9Y5
  28:     0x7faa08a947f0 - middle::trans::expr::trans::h212dc78148e7c0705h5
  29:     0x7faa08ad7b90 - middle::trans::expr::trans_addr_of::h921cc66a9f5ab965js7
  30:     0x7faa08acbce0 - middle::trans::expr::trans_unadjusted::h23078de2d39048ed9Y5
  31:     0x7faa08a93210 - middle::trans::expr::trans_into::hb8916173f4417b10be5
  32:     0x7faa08b5e440 - middle::trans::_match::store_local::closure.127862
  33:     0x7faa08b5e0d0 - middle::trans::_match::mk_binding_alloca::h6529477691948147476
  34:     0x7faa08b2d250 - middle::trans::_match::store_local::hb44613d070de7debY9k
  35:     0x7faa08a92860 - middle::trans::base::init_local::h133e0c8c07b0fc21mLg
  36:     0x7faa08a91c20 - middle::trans::controlflow::trans_stmt::hba2148511ea96f7fMp1
  37:     0x7faa08a93630 - middle::trans::controlflow::trans_block::h716e4eeaa8840a1bSu1
  38:     0x7faa08b34260 - middle::trans::base::trans_closure::h351dbed1a5bde932RFh
  39:     0x7faa08a86890 - middle::trans::base::trans_fn::h3693aec3731e5d78ERh
  40:     0x7faa08a840f0 - middle::trans::base::trans_item::h45f52e422775a7f1Sai
  41:     0x7faa08a840f0 - middle::trans::base::trans_item::h45f52e422775a7f1Sai
  42:     0x7faa08b3ea30 - middle::trans::base::trans_crate::h99c1d4d2a3b84039T8i
  43:     0x7faa08f90760 - driver::driver::phase_4_translate_to_llvm::h4ec643d39136fc7dAyC
  44:     0x7faa08f87600 - driver::driver::compile_input::h9bffb5cb96391869u5B
  45:     0x7faa0900a880 - driver::run_compiler::he276f2ba56b78164LVF
  46:     0x7faa0900a770 - driver::run::closure.146540
  47:     0x7faa08744ae0 - task::TaskBuilder<S>::try_future::closure.104852
  48:     0x7faa087448d0 - task::TaskBuilder<S>::spawn_internal::closure.104823
  49:     0x7faa08411c90 - task::NativeSpawner.Spawner::spawn::closure.8456
  50:     0x7faa08120150 - rust_try_inner
  51:     0x7faa08120140 - rust_try
  52:     0x7faa080c8b30 - unwind::try::h5eecabeb9eb443b7PGd
  53:     0x7faa080c89c0 - task::Task::run::h8328b0b81b516de7FMc
  54:     0x7faa084119d0 - task::NativeSpawner.Spawner::spawn::closure.8394
  55:     0x7faa080ca1d0 - thread::thread_start::h75cf1dc3cee75378U7c
  56:     0x7faa02f3d0c0 - start_thread
  57:     0x7faa07d942d9 - __clone
  58:                0x0 - <unknown>
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 28, 2014
@IdeaHat
Copy link
Author

IdeaHat commented Dec 2, 2014

Smaller example:

https://gist.github.com/IdeaHat/f14d0b8ae2703128e6ae

I'd guess it would be related to the fact that if they are static instead of const one gets the caught error:

 shared static items must have a type which implements Sync

A more leading compile error may help clarify what to do in this situation...

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Seems to no longer ICE:

#![crate_type = "lib"]

trait Qiz {
  fn qiz();
}

struct Foo;
impl Qiz for Foo {
  fn qiz() {}
}

struct Bar {
  foos: &'static [&'static (Qiz + 'static)]
}

const FOO : Foo = Foo;
const BAR : Bar = Bar { foos: &[&FOO]};
$ rustc lib.rs
lib.rs:17:33: 17:37 error: cannot convert to a trait object because trait `Qiz` is not object-safe [E0038]
lib.rs:17 const BAR : Bar = Bar { foos: &[&FOO]};
                                          ^~~~
lib.rs:17:33: 17:37 note: method `qiz` has no receiver
lib.rs:17 const BAR : Bar = Bar { foos: &[&FOO]};
                                          ^~~~
error: aborting due to previous error

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 21, 2015
@bors bors closed this as completed in 42123b7 May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants