Skip to content

Non-consecutive crate IDs triggering assert #13560

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
sfackler opened this issue Apr 16, 2014 · 4 comments · Fixed by #13565
Closed

Non-consecutive crate IDs triggering assert #13560

sfackler opened this issue Apr 16, 2014 · 4 comments · Fixed by #13565
Labels
A-syntaxext Area: Syntax extensions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sfackler
Copy link
Member

building sfackler/rust-postgres@650a030 triggers an assert inside of metadata::encoder:

task 'rustc' failed at 'assertion failed: `(left == right) && (right == left)` (left: `4`, right: `3`)', /home/sfackler/rust/rust/src/librustc/metadata/encoder.rs:1492
stack backtrace:
   1:     0x7f22ec4d88f0 - rt::backtrace::imp::write::h5dfe62f829bb8926qRa::v0.11.pre
   2:     0x7f22ec43a130 - rt::unwind::begin_unwind_inner::h656188078345464dTra::v0.11.pre
   3:     0x7f22ec439db0 - rt::unwind::begin_unwind_fmt::h0fa0fd6a17be09cb3qa::v0.11.pre
   4:     0x7f22ed5e0db0 - metadata::encoder::encode_metadata_inner::hf63f8d88e8b7eaa5o48::v0.11.pre
   5:     0x7f22ecf63b90 - metadata::encoder::encode_metadata::h6c0dd041c1ff6bb4S38::v0.11.pre
   6:     0x7f22ecf624e0 - middle::trans::base::write_metadata::h0a375886de86b464zbq::v0.11.pre
   7:     0x7f22ecf64190 - middle::trans::base::trans_crate::h03cceaf99acd8b6fugq::v0.11.pre
   8:     0x7f22ed697bb0 - driver::driver::phase_4_translate_to_llvm::h7b7bc374e3942267cAe::v0.11.pre
   9:     0x7f22ed699e20 - driver::driver::compile_input::h5aefc635514c08cd1Pe::v0.11.pre
  10:     0x7f22ed6be200 - run_compiler::h54519610e6366e1flom::v0.11.pre
  11:     0x7f22ed6d5900 - main_args::closure.91936
  12:     0x7f22ed6d4230 - monitor::closure.91821
  13:     0x7f22ed6cfb10 - task::TaskBuilder::try::closure.91587
  14:     0x7f22ef43fb90 - task::spawn_opts::closure.7971
  15:     0x7f22ec4d3920 - rt::task::Task::run::closure.40115
  16:     0x7f22ec4df4e0 - rust_try
  17:     0x7f22ec4d3760 - rt::task::Task::run::h88d5577d7084e0bafi8::v0.11.pre
  18:     0x7f22ef43f960 - task::spawn_opts::closure.7944
  19:     0x7f22ec4d7430 - rt::thread::thread_start::hc0c9989a147641340W8::v0.11.pre
  20:     0x7f22ebe13fe0 - start_thread
  21:     0x7f22ec10ece9 - clone
  22:                0x0 - <unknown>

Moving the #[phase(syntax)] extern crate rust_phf to the bottom of the crate list suppresses the issue. It looks like syntax-only crates are still taking a crate ID in creader which is creating "holes" at link-time. I tried simply removing the assert that tripped but that broke the world.

@sfackler
Copy link
Member Author

cc @alexcrichton

@alexcrichton
Copy link
Member

I think that I have a fix for this, but I'm unable to reproduce in a smaller test case. Do you know of a way to minimize to something other than rust-postgres?

@sfackler
Copy link
Member Author

I poked around a tiny bit last night but didn't find a repo. I'd imagine that it'd just be "link against a ton of crates with a syntax one somewhere in the middle". I can try to make another repro tonight.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 16, 2014
Syntax-only crates are no longer registered with the cstore, so there's no need
to allocate crate numbers to them. This ends up leaving gaps in the crate
numbering scheme which is not expected in the rest of the compiler.

Closes rust-lang#13560
@sfackler
Copy link
Member Author

Here's a very minimal test case:

#![feature(phase)]

#[phase(syntax)]
extern crate fourcc;
#[phase(syntax, link)]
extern crate log;

bors added a commit that referenced this issue Apr 17, 2014
Syntax-only crates are no longer registered with the cstore, so there's no need
to allocate crate numbers to them. This ends up leaving gaps in the crate
numbering scheme which is not expected in the rest of the compiler.

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

Successfully merging a pull request may close this issue.

2 participants