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

ICE when using a reference incorrectly in quick_error #68449

Closed
milkey-mouse opened this issue Jan 22, 2020 · 5 comments · Fixed by #68530
Closed

ICE when using a reference incorrectly in quick_error #68449

milkey-mouse opened this issue Jan 22, 2020 · 5 comments · Fixed by #68530
Assignees
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@milkey-mouse
Copy link

I was using the latest version of quick-error and tried to store a reference without a lifetime annotated in a macro-generated error. This shouldn't (and doesn't) work, but rustc should at least throw an error instead of blowing up, right?

Code sample:

use quick_error::quick_error;

quick_error! {
    pub enum AReferenceInQuickError {
        CrashesRustc(s: &str) {
            display("hello, {}!", s)
        }
    }
}

fn main() {
    let world = "world";
    AReferenceInQuickError::CrashesRustc(world);
}

I expected an error of some sort about lifetimes or macros, but instead, the compiler paniced:

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/main.rs"), BytePos(0)), end: (Macros("::quick_error::quick_error"), BytePos(7612215)) })', src/librustc_errors/lib.rs:197:29

Meta

This rustc was compiled on Gentoo from a recent master.

$ rustc --version --verbose
rustc 1.42.0-dev (2cf24ab89 2020-01-21)
binary: rustc
commit-hash: 2cf24ab89123532f0e84995301ee734a88bf4701
commit-date: 2020-01-21
host: x86_64-unknown-linux-gnu
release: 1.42.0-dev
LLVM version: 9.0

Minimal example: https://github.com/milkey-mouse/quick-error-ice
Backtrace: https://github.com/milkey-mouse/quick-error-ice/blob/master/backtrace

@csmoe csmoe added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 22, 2020
@csmoe

This comment has been minimized.

@csmoe csmoe closed this as completed Jan 22, 2020
@csmoe csmoe reopened this Jan 22, 2020
@csmoe
Copy link
Member

csmoe commented Jan 22, 2020

#68267 cc @estebank

@csmoe csmoe added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jan 22, 2020
@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jan 22, 2020
@Centril
Copy link
Contributor

Centril commented Jan 23, 2020

Backtrace:

   Compiling quick-error-ice v0.1.0 (/home/milkey/github/quick-error-ice)
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/main.rs"), BytePos(0)), end: (Macros("::quick_error::quick_error"), BytePos(7612215)) })', src/librustc_errors/lib.rs:197:29
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::result::unwrap_failed
  10: <unknown>
  11: <unknown>
  12: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
  13: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  14: rustc_errors::HandlerInner::emit_diagnostic
  15: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  16: <unknown>
  17: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_lifetime
  18: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_ty
  19: <unknown>
  20: <unknown>
  21: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_item
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: rustc::ty::context::TyCtxt::object_lifetime_defaults
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  36: <unknown>
  37: <unknown>
  38: <unknown>
  39: <unknown>
  40: <unknown>
  41: <unknown>
  42: <unknown>
  43: rustc_typeck::check_crate
  44: <unknown>
  45: <unknown>
  46: <unknown>
  47: <unknown>
  48: <unknown>
  49: <unknown>
  50: <unknown>
  51: <unknown>
  52: <unknown>
  53: __rust_maybe_catch_panic
  54: <unknown>
  55: <unknown>
  56: <unknown>
  57: <unknown>
  58: start_thread
  59: __clone
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: rustc 1.42.0-dev (2cf24ab89 2020-01-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [resolve_lifetimes] resolving lifetimes
#1 [object_lifetime_defaults_map] looking up lifetime defaults for a region
#2 [generics_of] processing `main`
#3 [collect_mod_item_types] collecting item types in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `quick-error-ice`.

To learn more, run the command again with --verbose.

@pnkfelix
Copy link
Member

triage: P-high, assigning to @estebank . (It would be good to confirm it is indeed due to the CC'ed PR via bisection...)

@pnkfelix pnkfelix added the P-high High priority label Jan 23, 2020
@estebank
Copy link
Contributor

estebank commented Jan 25, 2020

Full backtrace:

   Compiling no_main v0.1.0 (/Users/ekuber/workspace/asdf)
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: DistinctSources(DistinctSources { begin: (Real("src/main.rs"), BytePos(0)), end: (Macros("::quick_error::quick_error"), BytePos(7657333)) })', src/librustc_errors/lib.rs:197:29
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::sys_common::backtrace::print
   4: std::panicking::default_hook::{{closure}}
   5: std::panicking::default_hook
   6: rustc_driver::report_ice
   7: std::panicking::rust_panic_with_hook
   8: rust_begin_unwind
   9: core::panicking::panic_fmt
  10: core::result::unwrap_failed
  11: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  12: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  13: rustc_errors::CodeSuggestion::splice_lines
  14: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
  15: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
  16: rustc_errors::HandlerInner::emit_diagnostic
  17: rustc_errors::Handler::emit_diagnostic
  18: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  19: rustc_resolve::lifetimes::LifetimeContext::resolve_elided_lifetimes
  20: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_lifetime
  21: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_ty
  22: rustc_hir::intravisit::walk_struct_def
  23: rustc_hir::intravisit::walk_variant
  24: rustc_hir::intravisit::walk_item
  25: rustc_resolve::lifetimes::LifetimeContext::with
  26: <rustc_resolve::lifetimes::LifetimeContext as rustc_hir::intravisit::Visitor>::visit_item
  27: rustc_resolve::lifetimes::resolve_lifetimes
  28: rustc::ty::query::__query_compute::resolve_lifetimes
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: core::ops::function::FnOnce::call_once
  32: rustc::dep_graph::graph::DepGraph::with_task_impl
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  34: rustc::ty::context::TyCtxt::object_lifetime_defaults
  35: rustc_typeck::collect::generics_of
  36: rustc::ty::query::__query_compute::generics_of
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::generics_of>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  41: rustc::hir::map::Map::visit_item_likes_in_module
  42: rustc_typeck::collect::collect_mod_item_types
  43: rustc::ty::query::__query_compute::collect_mod_item_types
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  45: rustc::dep_graph::graph::DepGraph::with_task_impl
  46: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  48: rustc_session::session::Session::track_errors
  49: rustc_typeck::check_crate
  50: rustc_interface::passes::analysis
  51: rustc::ty::query::__query_compute::analysis
  52: rustc::dep_graph::graph::DepGraph::with_eval_always_task
  53: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  54: rustc::ty::context::tls::enter_global
  55: rustc_interface::interface::run_compiler_in_existing_thread_pool
  56: scoped_tls::ScopedKey<T>::set
  57: syntax::with_globals

From a quick look it seems like #68256 might tackle this. Rebuilding a recent master to confirm.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jan 25, 2020
Do not ICE on multipart suggestions touching multiple files

When encountering a multipart suggestion with spans belonging to
different contexts, skip that suggestion.

Fix rust-lang#68449. Similar to rust-lang#68256.
@bors bors closed this as completed in 6d3f4e0 Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants