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

ICE: the type `u8` has an unknown layout #36036

Closed
sinkuu opened this Issue Aug 27, 2016 · 10 comments

Comments

Projects
None yet
10 participants
@sinkuu
Copy link
Contributor

sinkuu commented Aug 27, 2016

(See #36036 (comment) for shorter example)

I tried this code:

extern crate futures;
extern crate tokio_core;
extern crate tokio_proto;

use futures::BoxFuture;
use futures::stream::BoxStream;
use std::error::Error as StdError;
use std::io;
use tokio_proto::Service;
use tokio_proto::proto::pipeline;
use tokio_proto::io::{Transport, Readiness};

fn main() {
    let service = ChunkedService {
        _inner: tokio_proto::simple_service(|vec| -> Result<Vec<u8>, io::Error> { Ok(vec) }),
    };
    pipeline::Server::new(service, Stream).unwrap();
}

pub type Frame = pipeline::Frame<Vec<u8>, Error>;

#[derive(Debug)]
pub struct Error;

impl From<pipeline::Error<Error>> for Error {
    fn from(_: pipeline::Error<Error>) -> Self {
        unimplemented!()
    }
}

pub struct ChunkedService<T> {
    _inner: T,
}

impl<T> Service for ChunkedService<T>
    where T: Service<Req = Vec<u8>, Resp = Vec<u8>>,
          T::Error: StdError
{
    type Req = Vec<u8>;
    type Resp = pipeline::Message<Vec<u8>, BoxStream<(), Error>>;
    type Error = Error;

    type Fut = BoxFuture<Self::Resp, Self::Error>;

    fn call(&self, _: Self::Req) -> Self::Fut {
        unimplemented!()
    }
}

struct Stream;

impl Transport for Stream {
    type In = Frame;
    type Out = Frame;
    fn read(&mut self) -> io::Result<Option<Self::Out>> {
        unimplemented!()
    }
    fn write(&mut self, _: Self::In) -> io::Result<Option<()>> {
        unimplemented!()
    }
    fn flush(&mut self) -> io::Result<Option<()>> {
        unimplemented!()
    }
}

impl Readiness for Stream {
    fn is_readable(&self) -> bool {
        false
    }
    fn is_writable(&self) -> bool {
        false
    }
}

impl io::Read for Stream {
    fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
        unimplemented!()
    }
}

impl io::Write for Stream {
    fn write(&mut self, _: &[u8]) -> io::Result<usize> {
        unimplemented!()
    }
    fn flush(&mut self) -> io::Result<()> {
        unimplemented!()
    }
}

with

  • tokio-core at b9395808bea624e6b64bcafbf6cc05cabdaca6cc,
  • tokio-proto at 9b694ed5d92a9614058674032a37836300727314
  • tokio-service at 821739abb9a9c138d84ea1a81c90809af7530e08
  • futures at ecbca61c8123eff5b939933d9fe0633b522be52b

I expected to see this happen: compilation success

Instead, this happened: crashed nightly and beta compiler

error: internal compiler error: ../src/librustc_trans/type_of.rs:155: failed to get layout for `tokio_proto::proto::pipeline::pipeline::Pipeline<tokio_proto::proto::pipeline::server::Dispatch<ChunkedService<tokio_proto::SimpleService<[closure@src/main.rs:15:45: 15:92], std::vec::Vec<u8>>>>, Stream>`: the type `u8` has an unknown layout

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:643
stack backtrace:
   1:     0x7fcd3eb42833 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:     0x7fcd3eb5311d - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:     0x7fcd3eb5166d - std::panicking::default_hook::h9e30d428ee3b0c43
   4:     0x7fcd3eb51d68 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:     0x7fcd37813387 - std::panicking::begin_panic::hd377747b5e679457
   6:     0x7fcd37823a48 - rustc_errors::Handler::bug::h5390c1898e6c2b8a
   7:     0x7fcd3bef0f2a - rustc::session::opt_span_bug_fmt::_{{closure}}::h7c6beff1b8c2acab
   8:     0x7fcd3be3d055 - rustc::session::opt_span_bug_fmt::h8b8cb70ab73590aa
   9:     0x7fcd3be3ce92 - rustc::session::bug_fmt::ha0645f57a1d17c87
  10:     0x7fcd3dd46ca2 - rustc_trans::type_of::sizing_type_of::hac6f4c390971a5ca
  11:     0x7fcd3dc863c3 - _<collections..vec..Vec<T> as core..iter..traits..FromIterator<T>>::from_iter::hc8dd23e1f341a34f
  12:     0x7fcd3dcafe5d - rustc_trans::adt::mk_struct::h99083854ab09bd5b
  13:     0x7fcd3dcad286 - rustc_trans::adt::represent_type::hd0a7f478d65fa630
  14:     0x7fcd3dd47a9d - rustc_trans::type_of::in_memory_type_of::h642c7fd5249a3167
  15:     0x7fcd3dd57e86 - rustc_trans::abi::FnType::unadjusted::_{{closure}}::h09238684ac765f3d
  16:     0x7fcd3dca946e - rustc_trans::abi::FnType::unadjusted::h881cc0f40154edcc
  17:     0x7fcd3dd00d79 - rustc_trans::declare::declare_fn::hb0a161c85d767c68
  18:     0x7fcd3dd3f657 - rustc_trans::trans_item::TransItem::predefine::h43bc091dbd423801
  19:     0x7fcd3dcbd8e1 - rustc_trans::base::trans_crate::hfc4e2ab878e1c72d
  20:     0x7fcd3ef0ba92 - rustc_driver::driver::phase_4_translate_to_llvm::hc799bcf39cd85f66
  21:     0x7fcd3ef46ad0 - rustc_driver::driver::compile_input::_{{closure}}::h688e4abb1bbb42bf
  22:     0x7fcd3ef386a0 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
  23:     0x7fcd3ee89b7f - rustc::ty::context::TyCtxt::create_and_enter::h0021bc4caf3a2e06
  24:     0x7fcd3eefb094 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
  25:     0x7fcd3ef2118d - rustc_driver::run_compiler::h184264500271cc39
  26:     0x7fcd3ee62c43 - std::panicking::try::do_call::h17a7a17ad7240c5c
  27:     0x7fcd3eb61336 - __rust_maybe_catch_panic
  28:     0x7fcd3ee80039 - _<F as alloc..boxed..FnBox<A>>::call_box::h95ef76c8d48c6f60
  29:     0x7fcd3eb4fba0 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
  30:     0x7fcd36fbb453 - start_thread
  31:     0x7fcd3e7a07de - __GI___clone
  32:                0x0 - <unknown>

Meta

rustc --version --verbose:

rustc 1.13.0-nightly (e07dd59ea 2016-08-25)
binary: rustc
commit-hash: e07dd59eaeb7be95afd2fb3dc131108ae750c91c
commit-date: 2016-08-25
host: x86_64-unknown-linux-gnu
release: 1.13.0-nightly
@koute

This comment has been minimized.

Copy link
Member

koute commented Aug 27, 2016

I'm also getting this ICE. Here's a more minimal example:

trait Context {
    type Container: ?Sized;
}

struct Wrapper< C: Context > where < C as Context >::Container: 'static {
    container: &'static C::Container
}

struct Foobar;

impl Context for Foobar {
    type Container = ();
}

fn foobar() -> Wrapper< Foobar > {
    unimplemented!();
}

fn main() {}

And here's the error:

error: internal compiler error: ../src/librustc_trans/type_of.rs:155: failed to get layout for `Wrapper<Foobar>`: the type `()` has an unknown layout

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', ../src/librustc_errors/lib.rs:644
stack backtrace:
   1:     0x7ffff756e833 - std::sys::backtrace::tracing::imp::write::h482d45d91246faa2
   2:     0x7ffff757f11d - std::panicking::default_hook::_{{closure}}::h89158f66286b674e
   3:     0x7ffff757d66d - std::panicking::default_hook::h9e30d428ee3b0c43
   4:     0x7ffff757dd68 - std::panicking::rust_panic_with_hook::h2224f33fb7bf2f4c
   5:     0x7fffefe18b97 - std::panicking::begin_panic::hd377747b5e679457
   6:     0x7fffefe2b208 - rustc_errors::Handler::bug::h5390c1898e6c2b8a
   7:     0x7ffff44f8f2a - rustc::session::opt_span_bug_fmt::_{{closure}}::h7c6beff1b8c2acab
   8:     0x7ffff4445055 - rustc::session::opt_span_bug_fmt::h8b8cb70ab73590aa
   9:     0x7ffff4444e92 - rustc::session::bug_fmt::ha0645f57a1d17c87
  10:     0x7ffff634eca2 - rustc_trans::type_of::sizing_type_of::hac6f4c390971a5ca
  11:     0x7ffff635fe94 - rustc_trans::abi::FnType::unadjusted::_{{closure}}::h09238684ac765f3d
  12:     0x7ffff62b146e - rustc_trans::abi::FnType::unadjusted::h881cc0f40154edcc
  13:     0x7ffff6308d79 - rustc_trans::declare::declare_fn::hb0a161c85d767c68
  14:     0x7ffff6347657 - rustc_trans::trans_item::TransItem::predefine::h43bc091dbd423801
  15:     0x7ffff62c58e1 - rustc_trans::base::trans_crate::hfc4e2ab878e1c72d
  16:     0x7ffff7937a92 - rustc_driver::driver::phase_4_translate_to_llvm::hc799bcf39cd85f66
  17:     0x7ffff7972ad0 - rustc_driver::driver::compile_input::_{{closure}}::h688e4abb1bbb42bf
  18:     0x7ffff79646a0 - rustc_driver::driver::phase_3_run_analysis_passes::_{{closure}}::h45e03cee16dcf298
  19:     0x7ffff78b5b7f - rustc::ty::context::TyCtxt::create_and_enter::h0021bc4caf3a2e06
  20:     0x7ffff7927094 - rustc_driver::driver::compile_input::hd9ecc57abd3cba85
  21:     0x7ffff794d18d - rustc_driver::run_compiler::h184264500271cc39
  22:     0x7ffff788ec43 - std::panicking::try::do_call::h17a7a17ad7240c5c
  23:     0x7ffff758d336 - __rust_maybe_catch_panic
  24:     0x7ffff78ac039 - _<F as alloc..boxed..FnBox<A>>::call_box::h95ef76c8d48c6f60
  25:     0x7ffff757bba0 - std::sys::thread::Thread::new::thread_start::he0bf102845911132
  26:     0x7ffff6cc7483 - start_thread
  27:     0x7ffff71c86dc - clone
  28:                0x0 - <unknown>

@sfackler sfackler added the I-ICE label Aug 27, 2016

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Aug 28, 2016

This is a regression from stable to beta.

@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Aug 28, 2016

Introduced in nightly-2016-08-13, changes from nightly-2016-08-12.

Slightly smaller example:

trait Context {
    type Container: ?Sized;
}

impl Context for u16 {
    type Container = u8;
}

struct Wrapper<C: Context> {
    container: *const C::Container
}

fn foobar(_: Wrapper<u16>) {}

fn main() {}
@TimNN

This comment has been minimized.

Copy link
Contributor

TimNN commented Aug 28, 2016

cc @eddyb, probably introduced as part of #35091.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Aug 28, 2016

Seems like pointers need to be normalized specially (as we don't recurse through them).

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Sep 1, 2016

triage: P-high

Assigning to @eddyb to start since he seems to have a clue what the problem is.

@rust-highfive rust-highfive added P-high and removed I-nominated labels Sep 1, 2016

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Sep 1, 2016

assigning to self to try to lift load from @eddyb

@pnkfelix pnkfelix assigned pnkfelix and unassigned eddyb Sep 1, 2016

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Sep 5, 2016

I have a fix in the works, will post PR soon.

pnkfelix added a commit to pnkfelix/rust that referenced this issue Sep 5, 2016

Fix issue rust-lang#36036.
We were treating an associated type as unsized even when the concrete
instantiation was actually sized. Fix is to normalize before checking
if it is sized.

bors added a commit that referenced this issue Sep 5, 2016

Auto merge of #36281 - pnkfelix:fix-issue-36036, r=eddyb
Fix issue #36036.

Fix #36036.

We were treating an associated type as unsized even when the concrete instantiation was actually sized. Fix is to normalize before checking if it is sized.

@bors bors closed this in #36281 Sep 5, 2016

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Sep 8, 2016

reopening since this is still a regression on beta

@pnkfelix pnkfelix reopened this Sep 8, 2016

jakllsch added a commit to jakllsch/rust that referenced this issue Sep 8, 2016

Fix issue rust-lang#36036.
We were treating an associated type as unsized even when the concrete
instantiation was actually sized. Fix is to normalize before checking
if it is sized.

brson added a commit to brson/rust that referenced this issue Sep 16, 2016

Fix issue rust-lang#36036.
We were treating an associated type as unsized even when the concrete
instantiation was actually sized. Fix is to normalize before checking
if it is sized.
@leodasvacas

This comment has been minimized.

Copy link
Contributor

leodasvacas commented Sep 17, 2016

This has been backported in #36538 so this issue may be closed.

@eddyb eddyb closed this Sep 17, 2016

pmatos pushed a commit to LinkiTools/rust that referenced this issue Sep 27, 2016

Fix issue rust-lang#36036.
We were treating an associated type as unsized even when the concrete
instantiation was actually sized. Fix is to normalize before checking
if it is sized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.