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 on closure typeck #66868

Closed
jothan opened this issue Nov 29, 2019 · 10 comments · Fixed by #71182
Closed

ICE on closure typeck #66868

jothan opened this issue Nov 29, 2019 · 10 comments · Fixed by #71182
Labels
A-closures Area: closures (`|args| { .. }`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jothan
Copy link

jothan commented Nov 29, 2019

I hit this problem while trying to make a task joining function. The problem occured when I started messing around with Arc<RwLock>.

The nightly compiler crashes on this too.

Problematic code:

Clone the smtpbis repo on the rustice branch.
https://github.com/zerospam/smtpbis.git

https://github.com/zerospam/smtpbis/commits/rustice
jothan/smtpbis@607ec56

Meta

rustc --version --verbose:
rustc 1.39.0 (4560ea7 2019-11-04)
binary: rustc
commit-hash: 4560ea7
commit-date: 2019-11-04
host: x86_64-unknown-linux-gnu
release: 1.39.0
LLVM version: 9.0

Backtrace:

RUST_BACKTRACE=1 cargo build --release
   Compiling smtpbis v0.1.4 (/home/joe/smtpbis)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1030
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  12: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:380
  13: rust_begin_unwind
             at src/libstd/panicking.rs:307
  14: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  15: core::panicking::panic
             at src/libcore/panicking.rs:49
  16: rustc_typeck::check::typeck_tables_of
  17: rustc::ty::query::__query_compute::typeck_tables_of
  18: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  19: rustc::dep_graph::graph::DepGraph::with_task_impl
  20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  21: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  22: rustc::dep_graph::graph::DepGraph::with_task_impl
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  24: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::note_obligation_cause
  25: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_selection_error
  26: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_fulfillment_errors
  27: rustc_typeck::check::FnCtxt::check_argument_types
  28: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
  29: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  30: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  31: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  32: rustc_typeck::check::FnCtxt::check_decl_initializer
  33: rustc_typeck::check::FnCtxt::check_decl_local
  34: rustc_typeck::check::FnCtxt::check_stmt
  35: rustc_typeck::check::FnCtxt::check_block_with_expected
  36: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  37: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  38: rustc_typeck::check::FnCtxt::check_block_with_expected
  39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  40: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  41: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  42: rustc_typeck::check::check_fn
  43: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
  44: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  45: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  46: rustc_typeck::check::FnCtxt::check_argument_types
  47: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
  48: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
  49: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  50: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  51: rustc_typeck::check::FnCtxt::check_argument_types
  52: rustc_typeck::check::FnCtxt::check_method_argument_types
  53: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  54: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  55: rustc_typeck::check::FnCtxt::check_block_with_expected
  56: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
  57: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
  58: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
  59: rustc_typeck::check::check_fn
  60: rustc::ty::context::GlobalCtxt::enter_local
  61: rustc_typeck::check::typeck_tables_of
  62: rustc::ty::query::__query_compute::typeck_tables_of
  63: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  64: rustc::dep_graph::graph::DepGraph::with_task_impl
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  66: rustc::ty::query::__query_compute::typeck_tables_of
  67: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  68: rustc::dep_graph::graph::DepGraph::with_task_impl
  69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  70: rustc_typeck::collect::checked_type_of
  71: rustc_typeck::collect::type_of
  72: rustc::ty::query::__query_compute::type_of
  73: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  74: rustc::dep_graph::graph::DepGraph::with_task_impl
  75: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  76: rustc::hir::intravisit::walk_expr
  77: rustc::hir::intravisit::walk_expr
  78: rustc::hir::intravisit::Visitor::visit_fn
  79: rustc::hir::intravisit::walk_item
  80: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
  81: rustc::hir::map::Map::visit_item_likes_in_module
  82: rustc_typeck::collect::collect_mod_item_types
  83: rustc::ty::query::__query_compute::collect_mod_item_types
  84: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  85: rustc::dep_graph::graph::DepGraph::with_task_impl
  86: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  87: rustc_typeck::check_crate::{{closure}}::{{closure}}
  88: rustc::util::common::time
  89: rustc_typeck::check_crate
  90: rustc_interface::passes::analysis
  91: rustc::ty::query::__query_compute::analysis
  92: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  93: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  94: rustc_interface::passes::create_global_ctxt::{{closure}}
  95: rustc_interface::interface::run_compiler_in_existing_thread_pool
  96: std::thread::local::LocalKey<T>::with
  97: scoped_tls::ScopedKey<T>::set
  98: syntax::with_globals
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.39.0 (4560ea788 2019-11-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 --crate-type bin

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

query stack during panic:
#0 [typeck_tables_of] processing `smtpbis::taskjoin::join_tasks`
#1 [typeck_tables_of] processing `smtpbis::taskjoin::join_tasks::{{closure}}#0`
#2 [typeck_tables_of] processing `main`
#3 [typeck_tables_of] processing `main::{{closure}}#0`
#4 [type_of] processing `main::{{closure}}#0`
#5 [collect_mod_item_types] collecting item types in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `smtpbis`.

To learn more, run the command again with --verbose.
@jothan
Copy link
Author

jothan commented Nov 29, 2019

Cargo.lock for exact reproduction:
Cargo.lock.txt

@jonas-schievink jonas-schievink added A-closures Area: closures (`|args| { .. }`) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2019
@Centril Centril added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Nov 29, 2019
@Centril
Copy link
Contributor

Centril commented Nov 29, 2019

Does this reproduce on nightly?

@jothan
Copy link
Author

jothan commented Nov 29, 2019

@Centril yes, I get the error using rustc 1.41.0-nightly (bbb664a 2019-11-28)

@basil-cow
Copy link
Contributor

basil-cow commented Dec 3, 2019

This line seems to be the culprit. It only exhibits when going over crate bound (at least I couldn't minify it further).

lib.rs:

use std::{
    future::Future,
    pin::Pin,
    sync::RwLock,
    task::{Context, Poll},
};

struct S {}

impl Future for S {
    type Output = ();
    fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
        Poll::Pending
    }
}

pub async fn f() {
    let fo = RwLock::new(S {});

    (&mut *fo.write().unwrap()).await;
}

main.rs in the binaries folder:

pub fn g<T>(task: T)
where
    T: Send,
{
}

fn main() {
    g(foo::f());
}

@Centril
Copy link
Contributor

Centril commented Dec 5, 2019

cc @davidtwco @nikomatsakis

@pnkfelix
Copy link
Member

pnkfelix commented Dec 5, 2019

triage: P-high, at least to identify whether this is a long-standing bug or a stable-to-stable regression. Removing nomination.

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Dec 5, 2019
@davidtwco davidtwco self-assigned this Dec 5, 2019
@estebank
Copy link
Contributor

estebank commented Dec 5, 2019

This won't build on 1.30:

~/workspace/proc-macro-workshop (proc-macro-workshop:HEAD 0)$ RUSTC_BOOTSTRAP=1 RUST_BACKTRACE=1 cargo +1.30.0 build
   Compiling proc-macro2 v1.0.6
   Compiling syn v1.0.11
   Compiling bitfield-impl v0.0.0 (/Users/ekuber/workspace/proc-macro-workshop/bitfield/impl)
   Compiling sorted v0.0.0 (/Users/ekuber/workspace/proc-macro-workshop/sorted)
error[E0432]: unresolved import `proc_macro`
error[E0432]: unresolved import `proc_macro`
 --> bitfield/impl/src/lib.rs:3:5
  |
3 | use proc_macro::TokenStream;
  |     ^^^^^^^^^^ Did you mean `self::proc_macro`?

 --> sorted/src/lib.rs:3:5
  |
3 | use proc_macro::TokenStream;
  |     ^^^^^^^^^^ Did you mean `self::proc_macro`?

error: aborting due to previous error
error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.

For more information about this error, try `rustc --explain E0432`.
error: Could not compile `sorted`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `bitfield-impl`.
warning: build failed, waiting for other jobs to finish...
error: build failed

estebank added a commit to estebank/rust that referenced this issue Dec 5, 2019
@estebank estebank added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 6, 2019
Centril added a commit to Centril/rust that referenced this issue Dec 6, 2019
@estebank estebank removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority labels Dec 14, 2019
@estebank
Copy link
Contributor

Removing I-ICE and P-high as the bug's been fixed in #67071, but leaving open to add a regression test.

Centril added a commit to Centril/rust that referenced this issue Dec 23, 2019
…-DPC

Add regression tests for fixed ICEs

Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01))
Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01))
Closes rust-lang#66270 (fixed by rust-lang#66246)
Closes rust-lang#66868 (fixed by rust-lang#67071)
Closes rust-lang#67424 (fixed by rust-lang#67160)

Also picking a minor nit up from rust-lang#67071 with 101dd7b

r? @Centril
Centril added a commit to Centril/rust that referenced this issue Dec 23, 2019
…-DPC

Add regression tests for fixed ICEs

Closes rust-lang#61747 (fixed from 1.41.0-nightly (4007d4e 2019-12-01))
Closes rust-lang#66205 (fixed from 1.41.0-nightly (4007d4e 2019-12-01))
Closes rust-lang#66270 (fixed by rust-lang#66246)
Closes rust-lang#66868 (fixed by rust-lang#67071)
Closes rust-lang#67424 (fixed by rust-lang#67160)

Also picking a minor nit up from rust-lang#67071 with 101dd7b

r? @Centril
@hellow554
Copy link
Contributor

@JohnTitor I'm confused. Did you add a testcase for this or not?

@JohnTitor
Copy link
Member

@hellow554 As discussed in #67543, we didn't add the test case there due to diffs of diagnostics on some environment.

@JohnTitor JohnTitor removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jan 13, 2020
@davidtwco davidtwco removed their assignment Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: closures (`|args| { .. }`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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.

9 participants