Skip to content

Panic in rustc, "trying to take the sizing type of std::io::Reader+'static, an unsized type" #18866

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
sivadeilra opened this issue Nov 11, 2014 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sivadeilra
Copy link

Hit panic in rustc.exe. Running on Windows 8.1 x64, using a nightly installed on Nov 8, 2014. Stack:

error: internal compiler error: trying to take the sizing type of std::io::Reader+'static, an unsized type
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>', C:\bot\slave\nightly-win-64\build\src\libsyntax\diagnostic.rs:175

stack backtrace:
   1:         0x69be0683 - ZN2rt9backtrace3imp5write20h7d3cc98a1c074a3c4CqE
   2:         0x69be426e - ZN2rt4init20h503f93975789e801YQqE
   3:         0x6878614d - ZN6unwind18begin_unwind_inner20hada8edd76acea962tqdE
   4:           0x6e5046 - ZN10diagnostic11SpanHandler8span_bug20h9d47bc833d281ca7H6FE
   5:           0x6e5707 - ZN10diagnostic7Handler3bug20hc57831817d0281fb4cGE
   6:         0x6f63dfe2 - ZN6middle5trans7type_of14sizing_type_of20h6a0f9da5ad461867vrcE
   7:         0x6f66a388 - ZN6middle5trans4meth10get_vtable20he8abc9103aaf6e32wCnE
   8:         0x6f6698aa - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
   9:         0x6f66bc0a - ZN6middle2ty9unsize_ty20hb656840a71e1b9c54PJE
  10:         0x6f66bd98 - ZN6middle2ty7mk_rptr20hc4fe8dad3aab9af65zHE
  11:         0x6f668eda - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
  12:         0x6f66877c - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
  13:         0x6f62e766 - ZN6middle5trans4expr5trans20hed70adbee69fdb705h5E
  14:         0x6f65d5dd - ZN6middle5trans6callee10trans_args20h531bcec3f7e4a317uP4E
  15:         0x6f634a45 - ZN6middle5trans6callee16trans_call_inner20hb1769e3e2feebe59ju4E
  16:         0x6f656650 - ZN6middle5trans6callee10trans_call20h7cf8e665fb545832Do4E
  17:         0x6f66657b - ZN6middle2ty9expr_kind20hb16159da47d8a59dNVJE
  18:         0x6f62caf4 - ZN6middle5trans4expr10trans_into20he7d3d8470dc69f4bbe5E
  19:         0x6f62bee0 - ZN6middle5trans11controlflow15trans_stmt_semi20h856c2a12f5f0afc5Zt1E
  20:         0x6f62b5d6 - ZN6middle5trans11controlflow10trans_stmt20hbb5073ab1d1be290Mp1E
  21:         0x6f62cd38 - ZN6middle5trans11controlflow11trans_block20h740139a0896d7f9fSu1E
  22:         0x6f6c85ac - ZN6middle5trans4base13trans_closure20h9e0b67a7cae79410RFhE
  23:         0x6f6204d7 - ZN6middle5trans4base8trans_fn20h44e9b1aabb8eca11ERhE
  24:         0x6f61ddf5 - ZN6middle5trans4base10trans_item20h32f020cee36631e1SaiE

I was able to boil this down to this minimal repro:

use std::io::Reader;

pub struct Foo {
    pub reader: Box<Reader +'static>
}

pub fn bar(reader: &mut Reader) {
}

pub fn new_Foo (reader: Box<Reader +'static>) -> Foo {
    let mut foo = Foo {
        reader: reader
    };
    bar(&mut foo.reader);
    foo
}

fn main() {}

Here's the stack from the minimal repro:

repro.rs:8:12: 8:18 warning: unused variable: `reader`, #[warn(unused_variables)] on by default
repro.rs:8 pub fn bar(reader: &mut Reader) {
                      ^~~~~~
repro.rs:11:1: 17:2 warning: function `new_Foo` should have a snake case name such as `new_foo`, #[warn(non_snake_case)] on by default
repro.rs:11 pub fn new_Foo (reader: Box<Reader +'static>) -> Foo {
repro.rs:12     let mut foo = Foo {
repro.rs:13         reader: reader
repro.rs:14     };
repro.rs:15     bar(&mut foo.reader);
repro.rs:16     foo
            ...
error: internal compiler error: trying to take the sizing type of std::io::Reader+'static, an unsized type
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>', C:\bot\slave\nightly-win-64\build\src\libsyntax\diagnostic.rs:175

stack backtrace:
   1:         0x69be0683 - ZN2rt9backtrace3imp5write20h7d3cc98a1c074a3c4CqE
   2:         0x69be426e - ZN2rt4init20h503f93975789e801YQqE
   3:         0x6878614d - ZN6unwind18begin_unwind_inner20hada8edd76acea962tqdE
   4:           0x5a5046 - ZN10diagnostic11SpanHandler8span_bug20h9d47bc833d281ca7H6FE
   5:           0x5a5707 - ZN10diagnostic7Handler3bug20hc57831817d0281fb4cGE
   6:         0x6f63dfe2 - ZN6middle5trans7type_of14sizing_type_of20h6a0f9da5ad461867vrcE
   7:         0x6f66a388 - ZN6middle5trans4meth10get_vtable20he8abc9103aaf6e32wCnE
   8:         0x6f6698aa - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
   9:         0x6f66bc0a - ZN6middle2ty9unsize_ty20hb656840a71e1b9c54PJE
  10:         0x6f66bd98 - ZN6middle2ty7mk_rptr20hc4fe8dad3aab9af65zHE
  11:         0x6f668eda - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
  12:         0x6f66877c - ZN6middle2ty34AutoAdjustment...std..clone..Clone5clone20h58ee77ee59949e13TaBE
  13:         0x6f62e766 - ZN6middle5trans4expr5trans20hed70adbee69fdb705h5E
  14:         0x6f65d5dd - ZN6middle5trans6callee10trans_args20h531bcec3f7e4a317uP4E
  15:         0x6f634a45 - ZN6middle5trans6callee16trans_call_inner20hb1769e3e2feebe59ju4E
  16:         0x6f656650 - ZN6middle5trans6callee10trans_call20h7cf8e665fb545832Do4E
  17:         0x6f66657b - ZN6middle2ty9expr_kind20hb16159da47d8a59dNVJE
  18:         0x6f62caf4 - ZN6middle5trans4expr10trans_into20he7d3d8470dc69f4bbe5E
  19:         0x6f62bee0 - ZN6middle5trans11controlflow15trans_stmt_semi20h856c2a12f5f0afc5Zt1E
  20:         0x6f62b5d6 - ZN6middle5trans11controlflow10trans_stmt20hbb5073ab1d1be290Mp1E
  21:         0x6f62cd38 - ZN6middle5trans11controlflow11trans_block20h740139a0896d7f9fSu1E
  22:         0x6f6c85ac - ZN6middle5trans4base13trans_closure20h9e0b67a7cae79410RFhE
  23:         0x6f6204d7 - ZN6middle5trans4base8trans_fn20h44e9b1aabb8eca11ERhE
  24:         0x6f61ddf5 - ZN6middle5trans4base10trans_item20h32f020cee36631e1SaiE
  25:         0x6f6d1228 - ZN6middle5trans4base11trans_crate20hc4a99ab77c7a9e55T8iE
  26:         0x6fb17839 - ZN6driver6driver25phase_4_translate_to_llvm20h0e9b62da92c317771xCE
  27:         0x6fb10c48 - ZN6driver6driver13compile_input20hc707f3b45cfe1b45V4BE
  28:         0x6fb8e890 - ZN6driver7monitor20hec7cfee49697b450QJGE
  29:         0x6fb8cc07 - ZN6driver7monitor20hec7cfee49697b450QJGE
  30:         0x6f2f9d95 - ZN6driver6driver35OutputFilenames...std..clone..Clone5clone20h9994a4236399fd5azUCE
  31:         0x6f2f9cd7 - ZN6driver6driver35OutputFilenames...std..clone..Clone5clone20h9994a4236399fd5azUCE
  32:         0x6b7aa94c - ZN4task15Ops.rt..Runtime4wrap20h3d79ff2f4629eb55dBeE
  33:         0x687e4c1f - rust_try
  34:         0x687e4bf9 - rust_try
  35:         0x6878433e - ZN6unwind3try20h559cbf9e76021bc6xddE
  36:         0x68784199 - ZN4task4Task3run20hc63e00547c72aae9HGcE
  37:         0x6b7aa780 - ZN4task15Ops.rt..Runtime4wrap20h3d79ff2f4629eb55dBeE
  38:         0x6878573d - ZN6thread7cleanup20hca042b881be0cf38x0cE
  39:     0x7ff9c1c516ad - BaseThreadInitThunk
@brandonson
Copy link
Contributor

I'm poking around at this, since something that seems the same bit me a bit earlier today as well. Not particularly familiar with internal compiler code though, so any tips are appreciated.

If I'm reading this right, the example should have failed during typeck (passing an &mut Box<Reader +'static> to bar where it should be an &mut Reader), so I'll start somewhere there.

@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 11, 2014
@erickt
Copy link
Contributor

erickt commented Jan 12, 2015

This does not ICE on OSX:

use std::io::Reader;

pub struct Foo {
    pub reader: Box<Reader +'static>
}

pub fn bar(reader: &mut Reader) {
}

pub fn new_Foo (reader: Box<Reader +'static>) -> Foo {
    let mut foo = Foo {
        reader: reader
    };
    bar(&mut foo.reader);
    foo
}

fn main() {}

produces:

bad2.rs:7:12: 7:18 warning: unused variable: `reader`, #[warn(unused_variables)] on by default
bad2.rs:7 pub fn bar(reader: &mut Reader) {
                     ^~~~~~
bad2.rs:10:1: 16:2 warning: function `new_Foo` should have a snake case name such as `new_foo`, #[warn(non_snake_case)] on by default
bad2.rs:10 pub fn new_Foo (reader: Box<Reader +'static>) -> Foo {
bad2.rs:11     let mut foo = Foo {
bad2.rs:12         reader: reader
bad2.rs:13     };
bad2.rs:14     bar(&mut foo.reader);
bad2.rs:15     foo
           ...

Could someone check if it still ICEs on Windows? If not, nominating this to be closed.

@JustAPerson
Copy link
Contributor

tl;dr: this bug appears to be fixed.
Updated for current Rust (on playpen as of today, 29 March 2015):

@sivadeilra's example compiles fine:

use std::io::Read;

pub struct Foo {
    pub reader: Box<Read +'static>
}

pub fn bar(reader: &mut Read) {
}

pub fn new_Foo (reader: Box<Read +'static>) -> Foo {
    let mut foo = Foo {
        reader: reader
    };
    bar(&mut foo.reader);
    foo
}

fn main() {}

@brandonson's concern is invalid. Box implements Read where T: Read, so this code should pass type checking.

@erickt although I wouldn't expect any issues on windows in particular, since this a bug in libsyntax, I went ahead and tested it on Window 8.1 x64 using today's nightly. Again, it compiles fine.

rustc 1.0.0-nightly (c89de2c56 2015-03-28) (built 2015-03-29)

@alexcrichton
Copy link
Member

Yay!

lnicola pushed a commit to lnicola/rust that referenced this issue Jan 7, 2025
…dfile-changes

Fix JSON project `PackageRoot` buildfile inclusion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants