Skip to content

ICE due to illegal move #22113

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
dlrobertson opened this issue Feb 9, 2015 · 1 comment
Closed

ICE due to illegal move #22113

dlrobertson opened this issue Feb 9, 2015 · 1 comment

Comments

@dlrobertson
Copy link
Contributor

I was playing around with unsafe blocks with the code listed below and it failed with the following.
System Info:

rustc 1.0.0-nightly (d3732a12e 2015-02-06 23:30:17 +0000)
host: 3.18.5-1-ARCH
architecture: x86_64

Example:

extern crate libc;
pub struct TestBuffer<T> {
    start: *mut T,
    size: usize,
    curr: isize,
}

impl<T: Send> TestBuffer<T> {
    pub fn new(value: T, size: usize) -> TestBuffer<T> {
        unsafe {
            let start = libc::malloc(
                (std::mem::size_of::<T>() * size)
                as libc::size_t) as *mut T;
            std::ptr::write(&mut *start, value);
            TestBuffer{start: start, size: size, curr: 0}
        }
    }
}

impl<T> Iterator for TestBuffer<T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        if self.curr < (self.size as isize) {
            self.curr += 1;
        } else {
            ()
        }
        unsafe { Some(*self.start.offset(self.curr - 1)) }
    }
}
```rust

Running with `RUST_BACKTRACE=1`:

Buff.rs:29:23: 29:56 error: internal compiler error: this path should not cause illegal move
Buff.rs:29 unsafe { Some(*self.start.offset(self.curr - 1)) }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
thread 'rustc' panicked at 'Box', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:129

stack backtrace:
1: 0x7f93ce6cd250 - sys::backtrace::write::h361f9c7ed16d6f6eUsy
2: 0x7f93ce6f0950 - failure::on_fail::h69f5f434699d11ccOWF
3: 0x7f93ce6507d0 - rt::unwind::begin_unwind_inner::hc4455d84b00b874blBF
4: 0x7f93cba20040 - rt::unwind::begin_unwind::h13236156776379767181
5: 0x7f93cba1ffd0 - diagnostic::SpanHandler::span_bug::h5ec31613fa5cf53fBUE
6: 0x7f93cc547270 - session::Session::span_bug::h5f8ab95419f97cb6xdq
7: 0x7f93cd8375e0 - borrowck::build_borrowck_dataflow_data::h3de5b29d7c85ab98gVe
8: 0x7f93cd833ed0 - borrowck::borrowck_fn::hac2da55ab2d59b33DSe
9: 0x7f93cd837440 - visit::walk_method_helper::h7515637727083481066
10: 0x7f93cd834ee0 - borrowck::borrowck_item::h918c0642f54f00c7BRe
11: 0x7f93cd8356f0 - borrowck::check_crate::h5c36e499d0e6ca76tMe
12: 0x7f93cecbfb20 - driver::phase_3_run_analysis_passes::h8f5a5e5500230bd1oGa
13: 0x7f93ceca5a40 - driver::compile_input::hcb43bced2a0b021bCba
14: 0x7f93ced77be0 - run_compiler::hb81cf958c2f963666ac
15: 0x7f93ced76270 - thunk::F.Invoke<A, R>::invoke::h6159218808669033746
16: 0x7f93ced751a0 - rt::unwind::try::try_fn::h8268217050585033268
17: 0x7f93ce75ca90 - rust_try_inner
18: 0x7f93ce75ca80 - rust_try
19: 0x7f93ced75450 - thunk::F.Invoke<A, R>::invoke::h8703575304585054118
20: 0x7f93ce6dce40 - sys::thread::thread_start::h35f66aa7ce5d7277LCB
21: 0x7f93c870f250 - start_thread
22: 0x7f93ce2d8219 - clone
23: 0x0 -

I'm still definitely a noobie just playing around, so this could definitely be my fault. Thanks in advance for the help. Any input or advice would also be appreciated.
@jdm
Copy link
Contributor

jdm commented Feb 9, 2015

Duplicate of #20801.

@jdm jdm closed this as completed Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants