rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.74k stars 12.64k forks source link

ICE when using Iron::listen. #18047

Closed reem closed 9 years ago

reem commented 10 years ago

This:

extern crate iron;

use iron::{Request, Response, IronResult, Iron, status};
use std::net::ip::Ipv4Addr;

fn main() {
    Iron::new(hello_world);

    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with(status::Ok, "hello world"))
    }
}

compiles fine, but:

extern crate iron;

use iron::{Request, Response, IronResult, Iron, status};
use std::net::ip::Ipv4Addr;

fn main() {
    Iron::new(hello_world).listen(Ipv4Addr(127, 0, 0, 1), 3000);

    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with(status::Ok, "hello world"))
    }
}

ICEs with:

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'no entry found for key', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libstd/collections/hashmap/map.rs:1093

stack backtrace:
   1:        0x10cebcd59 - rt::backtrace::imp::write::h189e19957ab9c695OLq
   2:        0x10cec0071 - failure::on_fail::h03dc2437e5a88345n2q
   3:        0x10d12ce95 - unwind::begin_unwind_inner::h033484cc1a8bac37Jud
   4:        0x109a37e7e - unwind::begin_unwind::h7267044357685618810
   5:        0x109f59800 - middle::ty::type_contents::tc_ty::h9dee7b4d0b2b2b26VCF
   6:        0x109f58f3c - middle::ty::type_contents::tc_ty::h9dee7b4d0b2b2b26VCF
   7:        0x109cdb5d6 - middle::ty::type_contents::h92aeb2c2b610e0e2QBF
   8:        0x109ee9fe9 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h14245152794985074657
   9:        0x109ee495f - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h5075202552449147342
  10:        0x109eea03e - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::consume_expr::h14245152794985074657
  11:        0x109ee495f - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h5075202552449147342
  12:        0x109eea293 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_local::h3960078952215051727
  13:        0x109eea1c5 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_block::h1681476813087692403
  14:        0x109ee4ab8 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h5075202552449147342
  15:        0x109eedd7a - middle::trans::_match::create_bindings_map::h7c926dcc9743685daOi
  16:        0x109e6336a - middle::trans::_match::trans_match::hda856724a8df18120Ji
  17:        0x109e51b37 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  18:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  19:        0x109e11e9c - middle::trans::controlflow::trans_stmt_semi::h690085bf4cf7dcecUCZ
  20:        0x109e11520 - middle::trans::controlflow::trans_stmt::hf3294d619d4310c2HyZ
  21:        0x109e12df8 - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  22:        0x109e16e78 - middle::trans::controlflow::trans_while::h5f1f833bc693e3166NZ
  23:        0x109e53a87 - middle::trans::expr::trans_rvalue_stmt_unadjusted::h429c506388a2e3d6LI4
  24:        0x109e12c64 - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  25:        0x109e12efd - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  26:        0x109e51bad - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  27:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  28:        0x109e12efd - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  29:        0x109ec399e - middle::trans::base::trans_closure::h7f2921f1f179d268ezf
  30:        0x109e667b5 - middle::trans::closure::trans_expr_fn::hfa0708e282a88c7eLFj
  31:        0x109e52a73 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  32:        0x109e50426 - middle::trans::expr::trans_unadjusted::hc4be1e5aa2eff2b4gb4
  33:        0x109e14056 - middle::trans::expr::trans::h49becb6a5c7b0a40cu3
  34:        0x109e497c4 - middle::trans::callee::trans_args::h82b5e82dbe357761802
  35:        0x109e1b801 - middle::trans::callee::trans_call_inner::hd16d8c5fe60896ffbG2
  36:        0x109e43814 - middle::trans::callee::trans_method_call::haf484f13878df218EB2
  37:        0x109e51646 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  38:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  39:        0x109e11e9c - middle::trans::controlflow::trans_stmt_semi::h690085bf4cf7dcecUCZ
  40:        0x109e11520 - middle::trans::controlflow::trans_stmt::hf3294d619d4310c2HyZ
  41:        0x109e12df8 - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  42:        0x109e18076 - middle::trans::controlflow::trans_for::h5d5ba302e1abeed7cQZ
  43:        0x109e53ac8 - middle::trans::expr::trans_rvalue_stmt_unadjusted::h429c506388a2e3d6LI4
  44:        0x109e12c64 - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  45:        0x109e12efd - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  46:        0x109ec399e - middle::trans::base::trans_closure::h7f2921f1f179d268ezf
  47:        0x109e0508a - middle::trans::base::trans_fn::hac9c962286515c42CKf
  48:        0x109e06f5e - middle::trans::monomorphize::monomorphic_fn::h96fb22308c4a0853u5Y
  49:        0x109e3dbcf - middle::trans::callee::trans_fn_ref_with_substs::hdc5652548ed88225tk2
  50:        0x109e3a3ab - middle::trans::callee::trans_fn_ref::hf590bd91aa7c0fd4181
  51:        0x109e1c24d - middle::trans::meth::trans_method_callee::h321387808d989836SRk
  52:        0x109e439bb - middle::trans::callee::trans_method_call::closure.123984
  53:        0x109e1a754 - middle::trans::callee::trans_call_inner::hd16d8c5fe60896ffbG2
  54:        0x109e43814 - middle::trans::callee::trans_method_call::haf484f13878df218EB2
  55:        0x109e51646 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  56:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  57:        0x109e12efd - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  58:        0x109e51bad - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  59:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  60:        0x109e12efd - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  61:        0x109ec399e - middle::trans::base::trans_closure::h7f2921f1f179d268ezf
  62:        0x109e667b5 - middle::trans::closure::trans_expr_fn::hfa0708e282a88c7eLFj
  63:        0x109e52a73 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  64:        0x109e50426 - middle::trans::expr::trans_unadjusted::hc4be1e5aa2eff2b4gb4
  65:        0x109e14056 - middle::trans::expr::trans::h49becb6a5c7b0a40cu3
  66:        0x109e497c4 - middle::trans::callee::trans_args::h82b5e82dbe357761802
  67:        0x109e1b801 - middle::trans::callee::trans_call_inner::hd16d8c5fe60896ffbG2
  68:        0x109e429a7 - middle::trans::callee::trans_call::hc740554d018cb851wA2
  69:        0x109e52201 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  70:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  71:        0x109e11e9c - middle::trans::controlflow::trans_stmt_semi::h690085bf4cf7dcecUCZ
  72:        0x109e11520 - middle::trans::controlflow::trans_stmt::hf3294d619d4310c2HyZ
  73:        0x109e12df8 - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  74:        0x109ec399e - middle::trans::base::trans_closure::h7f2921f1f179d268ezf
  75:        0x109e0508a - middle::trans::base::trans_fn::hac9c962286515c42CKf
  76:        0x109e06f5e - middle::trans::monomorphize::monomorphic_fn::h96fb22308c4a0853u5Y
  77:        0x109e3dbcf - middle::trans::callee::trans_fn_ref_with_substs::hdc5652548ed88225tk2
  78:        0x109e3a3ab - middle::trans::callee::trans_fn_ref::hf590bd91aa7c0fd4181
  79:        0x109e1c24d - middle::trans::meth::trans_method_callee::h321387808d989836SRk
  80:        0x109e439bb - middle::trans::callee::trans_method_call::closure.123984
  81:        0x109e1a754 - middle::trans::callee::trans_call_inner::hd16d8c5fe60896ffbG2
  82:        0x109e43814 - middle::trans::callee::trans_method_call::haf484f13878df218EB2
  83:        0x109e51646 - middle::trans::expr::trans_rvalue_dps_unadjusted::hc9fadfddd28f4d57KO4
  84:        0x109e12b9d - middle::trans::expr::trans_into::h61ab769bf22fa7c9iq3
  85:        0x109e11e9c - middle::trans::controlflow::trans_stmt_semi::h690085bf4cf7dcecUCZ
  86:        0x109e11520 - middle::trans::controlflow::trans_stmt::hf3294d619d4310c2HyZ
  87:        0x109e12df8 - middle::trans::controlflow::trans_block::haf894db31e0a118dNDZ
  88:        0x109ec399e - middle::trans::base::trans_closure::h7f2921f1f179d268ezf
  89:        0x109e0508a - middle::trans::base::trans_fn::hac9c962286515c42CKf
  90:        0x109e02805 - middle::trans::base::trans_item::h35195f56acc36a8eV3f
  91:        0x109ecd4d8 - middle::trans::base::trans_crate::h6442820c0a274264r2g
  92:        0x10a308615 - driver::driver::phase_4_translate_to_llvm::h8e1e0d5a654b87d1kAx
  93:        0x10a300718 - driver::driver::compile_input::h1f2de5081accd1dcf7w
  94:        0x10a389084 - driver::run_compiler::h00e7e552333d10b3yVA
  95:        0x10a3871b6 - driver::run::closure.147372
  96:        0x109a7034b - task::TaskBuilder<S>::try_future::closure.101547
  97:        0x109a70233 - task::TaskBuilder<S>::spawn_internal::closure.101518
  98:        0x10ad2179d - task::spawn_opts::closure.8528
  99:        0x10d19495c - rust_try_inner
  100:        0x10d194946 - rust_try
 ... <frames omitted>

I tried to debug this with @eddyb on IRC a few days ago, but haven't been able to make any progress.

reem commented 9 years ago

This is fixed in iron/master, but reproducible in https://github.com/reem/iron/tree/feat/taskpool HEAD.

Narrowing the code led to this:

Actual code from the feat/taskpool branch, src/iron.rs, lines 123-125:

// Dispatch the request
let res = handler.call(&mut req).map_err(|e| {
    handler.catch(&mut req, e)
});

ICES:

let res = handler.call(&mut req);

Fine:

let res: IronResult<Response> = fail!():
ghost commented 9 years ago

Potentially a duplicate of https://github.com/rust-lang/rust/issues/17810.

reem commented 9 years ago

This is currently holding back a PR that improves Iron's performance by 80%. I'd be willing to pursue a fix if somebody pointed me in the wrong direction, as I'd really like to land this change.

reem commented 9 years ago

I checked again just now and this actually appears to be fixed! Joyful times!