Skip to content

ICE on Hyper/Juniper Example #59344

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
andreytkachenko opened this issue Mar 21, 2019 · 5 comments
Closed

ICE on Hyper/Juniper Example #59344

andreytkachenko opened this issue Mar 21, 2019 · 5 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@andreytkachenko
Copy link

I am trying to compile hyper/juniper example:

#[macro_use]
extern crate juniper;
extern crate futures;

use futures::future;
use std::sync::Arc;
use hyper::rt::{self, Future};
use hyper::service::service_fn;
use hyper::Method;
use hyper::{Body, Response, Server, StatusCode};
use juniper::{FieldResult, RootNode};

struct Context;
impl juniper::Context for Context {}

#[derive(GraphQLObject)]
struct Human {
    id: String,
    home_planet: String,
}

#[derive(GraphQLInputObject)]
#[graphql(description = "A humanoid creature in the Star Wars universe")]
struct NewHuman {
    home_planet: String,
}

pub struct QueryRoot;

graphql_object!(QueryRoot: Context |&self| {
    field human(&executor, id: String) -> FieldResult<Human> {
        Ok(Human{
            id: "1234".to_owned(),
            home_planet: "Mars".to_owned(),
        })
    }
});

pub struct MutationRoot;

graphql_object!(MutationRoot: Context |&self| {
    field createHuman(&executor, new_human: NewHuman) -> FieldResult<Human> {
        Ok(Human {
            id: "1234".to_owned(),
            home_planet: new_human.home_planet,
        })
    }
});

pub type Schema = RootNode<'static, QueryRoot, MutationRoot>;

fn main() {
    let addr = ([127, 0, 0, 1], 3000).into();
    let ctx = Arc::new(Context);
    let root_node = Arc::new(Schema::new(QueryRoot {}, MutationRoot {}));

    let new_service = move || {
        let root_node = root_node.clone();
        let ctx = ctx.clone();

        service_fn(move |req| -> Box<dyn Future<Item = _, Error = _> + Send> {
            let root_node = root_node.clone();
            let ctx = ctx.clone();

            match (req.method(), req.uri().path()) {
                (&Method::GET, "/") => Box::new(juniper_hyper::graphiql("/graphql")),
                (&Method::GET, "/graphql") => Box::new(juniper_hyper::graphql(root_node, ctx, req)),
                (&Method::POST, "/graphql") => Box::new(juniper_hyper::graphql(root_node, ctx, req)),
                _ => {
                    let mut response = Response::new(Body::empty());
                    *response.status_mut() = StatusCode::NOT_FOUND;

                    Box::new(future::ok(response))
                }
            }
        })
    };
    let server = Server::bind(&addr)
        .serve(new_service)
        .map_err(|e| eprintln!("server error: {}", e));

    rt::run(server);
}

and got next ICE:

error: internal compiler error: src/librustc_mir/borrow_check/nll/universal_regions.rs:745: cannot convert `ReScope(Node(238))` to a region vid

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:634:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::bug_fmt
  14: rustc_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid::{{closure}}
  15: rustc_mir::borrow_check::nll::universal_regions::UniversalRegionIndices::to_region_vid
  16: rustc_mir::borrow_check::nll::type_check::constraint_conversion::ConstraintConversion::convert_all
  17: rustc_mir::borrow_check::nll::type_check::TypeChecker::prove_predicate
  18: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_rvalue
  19: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  20: rustc_mir::borrow_check::nll::type_check::type_check
  21: rustc_mir::borrow_check::nll::compute_regions
  22: rustc_mir::borrow_check::do_mir_borrowck
  23: rustc::ty::context::GlobalCtxt::enter_local
  24: rustc_mir::borrow_check::mir_borrowck
  25: rustc::ty::query::__query_compute::mir_borrowck
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  29: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_rvalue
  30: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  31: rustc_mir::borrow_check::nll::type_check::type_check
  32: rustc_mir::borrow_check::nll::compute_regions
  33: rustc_mir::borrow_check::do_mir_borrowck
  34: rustc::ty::context::GlobalCtxt::enter_local
  35: rustc_mir::borrow_check::mir_borrowck
  36: rustc::ty::query::__query_compute::mir_borrowck
  37: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  40: rustc_mir::borrow_check::nll::type_check::TypeChecker::check_rvalue
  41: rustc_mir::borrow_check::nll::type_check::TypeChecker::typeck_mir
  42: rustc_mir::borrow_check::nll::type_check::type_check
  43: rustc_mir::borrow_check::nll::compute_regions
  44: rustc_mir::borrow_check::do_mir_borrowck
  45: rustc::ty::context::GlobalCtxt::enter_local
  46: rustc_mir::borrow_check::mir_borrowck
  47: rustc::ty::query::__query_compute::mir_borrowck
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::mir_borrowck>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  51: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  52: rustc::util::common::time
  53: rustc_interface::passes::analysis
  54: rustc::ty::query::__query_compute::analysis
  55: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  56: rustc::dep_graph::graph::DepGraph::with_task_impl
  57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  58: rustc::ty::context::tls::enter_global
  59: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  60: rustc_interface::passes::create_global_ctxt::{{closure}}
  61: rustc_interface::passes::BoxedGlobalCtxt::enter
  62: rustc_interface::interface::run_compiler_in_existing_thread_pool
  63: std::thread::local::LocalKey<T>::with
  64: scoped_tls::ScopedKey<T>::set
  65: syntax::with_globals
query stack during panic:
#0 [mir_borrowck] processing `main::{{closure}}#0::{{closure}}#0`
#1 [mir_borrowck] processing `main::{{closure}}#0`
#2 [mir_borrowck] processing `main`
#3 [analysis] running analysis passes on this crate
end of query stack

Cargo.toml

# ...
[dependencies]
futures = "0.1"
hyper = "0.12"
juniper = "0.11.1"
juniper_hyper = "0.2.0"
@jonas-schievink jonas-schievink added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Mar 21, 2019
@jonas-schievink
Copy link
Contributor

Duplicate of #58840

@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2019

Due to various issues, the Rust developers do not currently have a reproducible test case for #58840, and thus its impossible to confirm whether this is a true duplicate of #58840.

While I hope we will have a test case for #58840 at some point in the future, it seems misleading and inefficient to have this bug (#59344) closed as a duplicate of #58840.

In particular, since this bug has a test case attached, then if that test case continues to persist in the current compiler, then its possible that resolving this bug would actually yield a solution to #58840. Or it might not. We don't know yet without first investigating the state of #59344 with respect to the current rustc compiler.

So, reopening and tagging P-high (since its an ICE).

@pnkfelix pnkfelix reopened this May 6, 2019
@pnkfelix pnkfelix added the P-high High priority label May 6, 2019
@pnkfelix
Copy link
Member

pnkfelix commented May 6, 2019

btw, @jonas-schievink , if there is important reason you wanted one of these two bugs closed, then I recommend closing #58840 as a duplicate of #59344.

I know the former is an older bug, and thus one would usually give it precedence (in terms of which is a duplicate of which); but since the latter has strictly more useful information for T-compiler currently, it seems that should outweigh age in this case.

@jonas-schievink
Copy link
Contributor

Okay, I don't mind either way. I just closed this since it had the exact same backtrace as #58840. We can keep both open if this is not clearly a duplicate.

@pnkfelix
Copy link
Member

okay at this point I have verified that this no longer ICE's as of the latest nightly. This does seem like it was indeed a duplicate of #58840.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants