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

Compiler Panic (capacity overflow from CodeMap::span_to_lines ) #24954

Closed
gsquire opened this issue Apr 29, 2015 · 7 comments
Closed

Compiler Panic (capacity overflow from CodeMap::span_to_lines ) #24954

gsquire opened this issue Apr 29, 2015 · 7 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@gsquire
Copy link
Contributor

gsquire commented Apr 29, 2015

Code:
I got an unexpected compiler panic today when trying to compile this gist.

Back trace:
I realize the code does not build on my end, but the compiler panicked and output this with RUST_BACKTRACE=1.

Meta

rustc --version --verbose:

  • rustc 1.0.0-beta.2 (e9080ec 2015-04-16) (built 2015-04-16)
  • binary: rustc
  • commit-hash: e9080ec
  • commit-date: 2015-04-16
  • build-date: 2015-04-16
  • host: i686-unknown-linux-gnu
  • release: 1.0.0-beta.2
@pnkfelix pnkfelix changed the title Compiler Panic Compiler Panic (capacity overflow from CodeMap::span_to_lines ) Apr 29, 2015
@pnkfelix
Copy link
Member

@gsquire if you cannot reduce it down to a standalone set of files, it might be easier for us if you share a cargo repo and commit id, rather than us having to guess what version of the external crates we need to attempt to reproduce.

@gsquire
Copy link
Contributor Author

gsquire commented Apr 29, 2015

@pnkfelix Would you like me to post my Cargo.toml file? Would that be sufficient?

@pnkfelix
Copy link
Member

@gsquire yeah that would be great

@gsquire
Copy link
Contributor Author

gsquire commented Apr 29, 2015

@pnkfelix Here it is:

[package]
name = "cloud"
version = "0.1.0"
authors = ["Garrett Squire <garrettsquire@gmail.com>"]

[dependencies.nickel]

git = "https://github.com/nickel-org/nickel.rs.git"

[dependencies.hyper]

git = "https://github.com/hyperium/hyper.git"

[dependencies]

rustc-serialize = "0.3"

Sorry I didn't think to add that in the first place. If there is anything else you need, let me know.

@pnkfelix
Copy link
Member

(okay I've replicated locally now)

@pnkfelix pnkfelix added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 29, 2015
pnkfelix added a commit to pnkfelix/rust that referenced this issue Apr 30, 2015
There a number of recent issues that report the bug here.  See
e.g. rust-lang#24761 and rust-lang#24954.

This change does *not* fix them; it just makes the assert more
immediate (and also injects a more conservative check, in that we are
also checking that the files match up).

So, this does not directly fix any bugs, and is expected ot actually
inject new ICE's.  But those will all represent latent bugs that need
fixing.
pnkfelix added a commit to pnkfelix/rust that referenced this issue Apr 30, 2015
Make `span_to_lines` to return a `Result`.
(This is better than just asserting internally, since it allows caller
to decide if they can recover from the problem.)

Added type alias for `FileLinesResult` returned by `span_to_lines`.

Update embedded unit test to reflect `span_to_lines` signature change.

In diagnostic, catch `Err` from `span_to_lines` and print
`"(unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See
e.g. rust-lang#24761 and rust-lang#24954.

This change *might* fix them. However, that is not its main goal.
The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are
    also checking that the files match up.
@rprichard
Copy link
Contributor

I hit this bug (probably). I made a reduced test case:

macro_rules! foo {
    ($y:expr) => ({
        $y = 2;
    })
}

fn main() {
    let x = 1;
    foo!(x);
}
test.rs:9:10: 3:15 error: re-assignment of immutable variable `x`
error: internal compiler error: unexpected panic
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 'capacity overflow', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:330

stack backtrace:
   1:     0x7f343bf6dee9 - sys::backtrace::write::h9d474f8e9af32ff4eas
   2:     0x7f343bf75a29 - panicking::on_panic::h780bc016e25d560eHOw
   3:     0x7f343bf36a52 - rt::unwind::begin_unwind_inner::he10b5af763481bfaRtw
   4:     0x7f343bf37817 - rt::unwind::begin_unwind_fmt::h9bb9f2d65e37b92bXsw
   5:     0x7f343bf75606 - rust_begin_unwind
   6:     0x7f343bfc1dd4 - panicking::panic_fmt::h11c0222b0ca0e381hJy
   7:     0x7f34392c59cf - codemap::CodeMap::span_to_lines::h669ff35ac8bd1b88tLA
   8:     0x7f343930cc27 - diagnostic::emit::h65da8787fd9d4fc9spC
   9:     0x7f343930a9e4 - diagnostic::EmitterWriter.Emitter::emit::he3bafb0e40df4f46amC
  10:     0x7f34392bcba1 - diagnostic::SpanHandler::span_err::h5614c50f1c18ca09gSB
  11:     0x7f3439f2519d - session::Session::span_err::h3d8ac9553125fc59WGq
  12:     0x7f343a81195e - borrowck::check_loans::CheckLoanCtxt<'a, 'tcx>.euv..Delegate<'tcx>::mutate::h43caac2e19e577aeyla
  13:     0x7f343a821c56 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::mutate_expr::h7171415938733347731
  14:     0x7f343a81ef08 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_expr::h2675070928678527945
  15:     0x7f343a821a23 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::consume_expr::h17812453369581463546
  16:     0x7f343a81eece - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_expr::h2675070928678527945
  17:     0x7f343a821a23 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::consume_expr::h17812453369581463546
  18:     0x7f343a813ede - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'tcx, TYPER>::walk_fn::h21981989491015306
  19:     0x7f343a83bc0b - borrowck::borrowck_fn::h480089f89c2a71e5NOe
  20:     0x7f343a83b20f - borrowck::BorrowckCtxt<'a, 'tcx>.Visitor<'v>::visit_fn::h7c2e2fb9b1bcd595bGe
  21:     0x7f343a83e436 - visit::walk_item::h11293387340257430338
  22:     0x7f343a83dd39 - borrowck::check_crate::h6ae0d2f7513822c4QIe
  23:     0x7f343c4bc2e7 - driver::phase_3_run_analysis_passes::h876ca40ef22f652btGa
  24:     0x7f343c49bfec - driver::compile_input::h19dbb81f9d079a10Qba
  25:     0x7f343c554dc1 - run_compiler::h6fdcc5ae4819da2c65b
  26:     0x7f343c552612 - boxed::F.FnBox<A>::call_box::h15867338134671801927
  27:     0x7f343c551bd9 - rt::unwind::try::try_fn::h10571205104630549427
  28:     0x7f343bfe92f8 - rust_try_inner
  29:     0x7f343bfe92e5 - rust_try
  30:     0x7f343c551e74 - boxed::F.FnBox<A>::call_box::h11752498478748955554
  31:     0x7f343bf747c1 - sys::thread::Thread::new::thread_start::h9f92b31902592327dAv
  32:     0x7f3436005181 - start_thread
  33:     0x7f343bbba47c - __clone
  34:                0x0 - <unknown>

rustc 1.1.0-nightly (c42c1e7a6 2015-05-02) (built 2015-05-02)
binary: rustc
commit-hash: c42c1e7a678a27bb63c24fb1eca2866af4e3ab7a
commit-date: 2015-05-02
build-date: 2015-05-02
host: x86_64-unknown-linux-gnu
release: 1.1.0-nightly

pnkfelix added a commit to pnkfelix/rust that referenced this issue May 4, 2015
Make `span_to_lines` to return a `Result`.
(This is better than just asserting internally, since it allows caller
to decide if they can recover from the problem.)

Added type alias for `FileLinesResult` returned by `span_to_lines`.

Update embedded unit test to reflect `span_to_lines` signature change.

In diagnostic, catch `Err` from `span_to_lines` and print
`"(internal compiler error: unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See
e.g. rust-lang#24761 and rust-lang#24954.

This change *might* fix them. However, that is not its main goal.
The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are
    also checking that the files match up.
pnkfelix added a commit to pnkfelix/rust that referenced this issue May 5, 2015
Make `span_to_lines` to return a `Result`.
(This is better than just asserting internally, since it allows caller
to decide if they can recover from the problem.)

Added type alias for `FileLinesResult` returned by `span_to_lines`.

Update embedded unit test to reflect `span_to_lines` signature change.

In diagnostic, catch `Err` from `span_to_lines` and print
`"(internal compiler error: unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See
e.g. rust-lang#24761 and rust-lang#24954.

This change *might* fix them. However, that is not its main goal.
The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are
    also checking that the files match up.
bors added a commit that referenced this issue May 7, 2015
Guard against overflow in `codemap::span_to_lines`.

(Revised/expanded version of PR #24976)

Make `span_to_lines` to return a `Result`.

In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See e.g. #24761 and #24954.

This change *might* fix them. However, that is *not* its main goal. The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are also checking that the files match up.

----

As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
bors added a commit that referenced this issue May 7, 2015
Guard against overflow in `codemap::span_to_lines`.

(Revised/expanded version of PR #24976)

Make `span_to_lines` to return a `Result`.

In `diagnostic`, catch `Err` from `span_to_lines` and print `"(unprintable span)"` instead.

----

There a number of recent issues that report the bug here.  See e.g. #24761 and #24954.

This change *might* fix them. However, that is *not* its main goal. The main goals are:

 1. Make it possible for callers to recover from an error here, and

 2. Insert a more conservative check, in that we are also checking that the files match up.

----

As a drive-by, fix #24997 , which was causing my attempts to `make check-stage1` on an `--enable-debug` build to fail.
@bltavares
Copy link
Contributor

I had to change the code slightly to get it to compile, making the variable mutable. It compiled without ICE with the following code.

macro_rules! foo {
    ($y:expr) => ({
        $y = 2;
    })
}

fn main() {
    let mut x = 1;
    foo!(x);
}

bltavares pushed a commit to bltavares/glacier that referenced this issue Oct 28, 2015
@steveklabnik steveklabnik added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Oct 29, 2015
bltavares added a commit to bltavares/rust that referenced this issue Nov 3, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Nov 4, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

5 participants