Skip to content

Capacity overflow or unprintable scan ICE when an error occurs when calling a function provided to a macro #26094

Closed
@daboross

Description

@daboross

Here's an example:

macro_rules! some_macro {
    ($other: expr) => ({
        $other(None)
    })
}

fn some_function() {
}

fn main() {
    some_macro!(some_function);
}

The panic occurs seemingly if there is any error at all inside the () after $other. I just had providing an extra argument as an example, though having any kind of code error inside those braces produces this.

Output from 1.0 stable:

$ RUST_BACKTRACE=1 rustc example.rs
example.rs:11:17: 3:21 error: this function takes 0 parameters but 1 parameter was supplied [E0061]
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/stable-dist-rustc-linux/build/src/libcore/option.rs:330

stack backtrace:
   1:     0x7f50a6735449 - sys::backtrace::write::hbc46dc0cfb3b9537d4r
   2:     0x7f50a673d156 - panicking::on_panic::h74d3c14d86c58ac8jrw
   3:     0x7f50a6700462 - rt::unwind::begin_unwind_inner::h382cea404b11eb00t6v
   4:     0x7f50a670110c - rt::unwind::begin_unwind_fmt::h5c14cfc30901d9d274v
   5:     0x7f50a673cd36 - rust_begin_unwind
   6:     0x7f50a6789064 - panicking::panic_fmt::h9ea3571c30b632b3wwy
   7:     0x7f50a3c8967f - codemap::CodeMap::span_to_lines::hce1c500ecc8eee0doiA
   8:     0x7f50a3cce5c7 - diagnostic::emit::h24e89ba7e5b01060mTB
   9:     0x7f50a3ccc414 - diagnostic::EmitterWriter.Emitter::emit::hea68345bf5867ea44PB
  10:     0x7f50a3cca96b - diagnostic::SpanHandler::span_err_with_code::h0ceccd6fc81b0a2eEmB
  11:     0x7f50a456669a - session::Session::span_err_with_code::hcbfda103ccc8609aRxq
  12:     0x7f50a55705d1 - check::check_argument_types::h9424757d84871b0c6Hp
  13:     0x7f50a556e01b - check::callee::confirm_builtin_call::h513ef322dab07ec582l
  14:     0x7f50a556c8b1 - check::callee::check_call::h9f7647a0d5b2299bQTl
  15:     0x7f50a55c33b9 - check::check_expr_with_unifier::h7613982835395653666
  16:     0x7f50a5587f4d - check::check_block_with_expected::h31a6d6204e48ff42nUr
  17:     0x7f50a55cf66e - check::check_expr_with_unifier::h6071885822603894829
  18:     0x7f50a5587bc4 - check::check_block_with_expected::h31a6d6204e48ff42nUr
  19:     0x7f50a556a6c6 - check::check_fn::h1656833949835747UGn
  20:     0x7f50a5583594 - check::check_bare_fn::h1ca89f422d965ecetwn
  21:     0x7f50a55816f2 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h29ccc99d00d684a7wtn
  22:     0x7f50a564569a - check_crate::closure.38028
  23:     0x7f50a5640a30 - check_crate::h22dcd95e17a2d96dXcC
  24:     0x7f50a6c79cc8 - driver::phase_3_run_analysis_passes::h43926ceca86caa9fnGa
  25:     0x7f50a6c5adc5 - driver::compile_input::hb78754f2f33c01efQba
  26:     0x7f50a6d1c4d1 - run_compiler::h258d36d5501c1cdfz4b
  27:     0x7f50a6d1a122 - boxed::F.FnBox<A>::call_box::h7239693171334256553
  28:     0x7f50a6d19659 - rt::unwind::try::try_fn::h14329119008520845439
  29:     0x7f50a67afac8 - rust_try_inner
  30:     0x7f50a67afab5 - rust_try
  31:     0x7f50a6d19908 - boxed::F.FnBox<A>::call_box::h17332056298259451807
  32:     0x7f50a673c041 - sys::thread::create::thread_start::h490278b5c3c0b49faqv
  33:     0x7f50a0fbe181 - start_thread
  34:     0x7f50a638647c - __clone
  35:                0x0 - <unknown>

There's a different error when running with either 1.1-beta or 1.2-nightly (rustc 1.1.0-beta (cd7d89af9 2015-05-16) (built 2015-05-16) and rustc 1.2.0-nightly (613e57b44 2015-06-01) (built 2015-06-02) have the exact same error output). It's nicer, explaining the issue, though still has an ICE. It doesn't seem to produce a backtrace even if run with RUST_BACKTRACE=1 (on both 1.1 beta and 1.2 nightly).

$ RUST_BACKTRACE=1 rustc example.rs 
example.rs:11:17: 3:21 error: this function takes 0 parameters but 1 parameter was supplied [E0061]
(internal compiler error: unprintable span)
example.rs:1:1: 5:2 note: in expansion of some_macro!
example.rs:11:5: 11:32 note: expansion site
error: aborting due to previous error

This may be related to #25793 and #24761, though I think the code this is produced with is fairly different which is why I'm making a separate issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions