Skip to content

Rustc hangs and consumes all cpu and memory after finding illegal borrow. #4584

@jakerr

Description

@jakerr

I'm sorry, I haven't had the chance to check this on latest incoming so may already be fixed.

Version info:
rustc 0.6 (09bb07b 2012-12-24 18:29:02 -0800)
host: x86_64-apple-darwin

rustc hangs, consumes 100% CPU, and eventually 100% of memory when trying to compile this invalid program:

fn main() {
  let mut orig = @1;
  let mut borrow = &*orig;
  io::println(fmt!("before mutate, orig: %? borrow: %?", orig, borrow));
  orig = @2;
  borrow = &3; // Error here.
  io::println(fmt!("after mutate,  orig: %? borrow: %?", orig, borrow));
}

The error is reported like so:

$ rustc try.rs 
try.rs:6:12: 6:13 error: illegal borrow: borrowed value does not live long enough
try.rs:6   borrow = &3; // Error here.
                     ^
try.rs:1:10: 1:0 note: borrowed pointer must be valid for the block at 1:10...
try.rs:1 fn main() {

And then rustc hangs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions