actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.6k stars 1.67k forks source link

error: cannot recursively call into `Core` #220

Closed bbigras- closed 6 years ago

bbigras- commented 6 years ago

I just updated actix-web from 0.3.3 to 0.6.3 and I got this error:

main.rs:125 is an await!() from futures-await.

hread 'arbiter:"5abb53d1-5de5-4c7d-833e-443d95e91324":"actor"' panicked at 'cannot recursively call into `Core`', libcore/option.rs:914:5
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 libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:463
   5: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:350
   6: rust_begin_unwind
             at libstd/panicking.rs:328
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   8: core::option::expect_failed
             at libcore/option.rs:914
   9: <core::option::Option<T>>::expect
             at /checkout/src/libcore/option.rs:302
  10: tokio_core::reactor::Core::run
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:224
  11: ldap3::conn::LdapConn::with_settings
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/ldap3-0.6.0/src/conn.rs:211
  12: ldap3::conn::LdapConn::new
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/ldap3-0.6.0/src/conn.rs:203
  13: rs_nginx_auth::ldap::test_login
             at src/ldap.rs:85
  14: rs_nginx_auth::ldap::login::{{closure}}
             at src/ldap.rs:172
  15: <futures_await::__rt::GenFuture<T> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-await-0.1.1/src/lib.rs:120
  16: <futures::future::chain::Chain<A, B, C>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/chain.rs:26
  17: <futures::future::and_then::AndThen<A, B, F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/and_then.rs:32
  18: rs_nginx_auth::index_sub::{{closure}}
             at src/main.rs:125
  19: <futures_await::__rt::GenFuture<T> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-await-0.1.1/src/lib.rs:120
  20: <futures::future::chain::Chain<A, B, C>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/chain.rs:26
  21: <futures::future::then::Then<A, B, F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/then.rs:32
  22: <futures::future::map_err::MapErr<A, F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/map_err.rs:30
  23: <futures::future::chain::Chain<A, B, C>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/chain.rs:26
  24: <futures::future::then::Then<A, B, F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/then.rs:32
  25: <alloc::boxed::Box<F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/mod.rs:113
  26: <actix_web::pipeline::WaitingResponse<S, H>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/pipeline.rs:330
  27: <actix_web::pipeline::PipelineState<S, H>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/pipeline.rs:60
  28: <actix_web::pipeline::Pipeline<S, H> as actix_web::server::HttpHandlerTask>::poll_io
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/pipeline.rs:200
  29: <actix_web::server::h1::Http1<T, H>>::poll_handler
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/server/h1.rs:196
  30: <actix_web::server::h1::Http1<T, H>>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/server/h1.rs:135
  31: <actix_web::server::channel::HttpChannel<T, H> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-0.6.3/src/server/channel.rs:111
  32: <alloc::boxed::Box<F> as futures::future::Future>::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/future/mod.rs:113
  33: <futures::task_impl::Spawn<T>>::poll_future_notify::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/task_impl/mod.rs:289
  34: <futures::task_impl::Spawn<T>>::enter::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/task_impl/mod.rs:363
  35: futures::task_impl::std::set
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/task_impl/std/mod.rs:78
  36: <futures::task_impl::Spawn<T>>::enter
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/task_impl/mod.rs:363
  37: <futures::task_impl::Spawn<T>>::poll_future_notify
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-0.1.21/src/task_impl/mod.rs:289
  38: <tokio::executor::current_thread::scheduler::Scheduled<'a, U>>::tick
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/scheduler.rs:352
  39: <tokio::executor::current_thread::scheduler::Scheduler<U>>::tick::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/scheduler.rs:332
  40: <tokio::executor::current_thread::Borrow<'a, U>>::enter::{{closure}}::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:688
  41: tokio::executor::current_thread::CurrentRunner::set_spawn
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:720
  42: <tokio::executor::current_thread::Borrow<'a, U>>::enter::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:687
  43: <std::thread::local::LocalKey<T>>::try_with
             at /checkout/src/libstd/thread/local.rs:294
  44: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/libstd/thread/local.rs:248
  45: <tokio::executor::current_thread::Borrow<'a, U>>::enter
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:686
  46: <tokio::executor::current_thread::scheduler::Scheduler<U>>::tick
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/scheduler.rs:332
  47: <tokio::executor::current_thread::Entered<'a, P>>::tick
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:572
  48: <tokio::executor::current_thread::Entered<'a, P>>::turn
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.1.6/src/executor/current_thread/mod.rs:515
  49: tokio_core::reactor::Core::poll::{{closure}}::{{closure}}::{{closure}}::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:298
  50: <scoped_tls::ScopedKey<T>>::set
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.2/src/lib.rs:155
  51: tokio_core::reactor::Core::poll::{{closure}}::{{closure}}::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:297
  52: tokio_timer::timer::handle::with_default::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.3/src/timer/handle.rs:64
  53: <std::thread::local::LocalKey<T>>::try_with
             at /checkout/src/libstd/thread/local.rs:294
  54: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/libstd/thread/local.rs:248
  55: tokio_timer::timer::handle::with_default
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-timer-0.2.3/src/timer/handle.rs:56
  56: tokio_core::reactor::Core::poll::{{closure}}::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:275
  57: tokio_executor::global::with_default::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-executor-0.1.2/src/global.rs:176
  58: <std::thread::local::LocalKey<T>>::try_with
             at /checkout/src/libstd/thread/local.rs:294
  59: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/libstd/thread/local.rs:248
  60: tokio_executor::global::with_default
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-executor-0.1.2/src/global.rs:150
  61: tokio_core::reactor::Core::poll::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:274
  62: tokio_reactor::with_default::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-reactor-0.1.1/src/lib.rs:207
  63: <std::thread::local::LocalKey<T>>::try_with
             at /checkout/src/libstd/thread/local.rs:294
  64: <std::thread::local::LocalKey<T>>::with
             at /checkout/src/libstd/thread/local.rs:248
  65: tokio_reactor::with_default
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-reactor-0.1.1/src/lib.rs:199
  66: tokio_core::reactor::Core::poll
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:273
  67: tokio_core::reactor::Core::run
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-core-0.1.17/src/reactor/mod.rs:248
  68: actix::arbiter::Arbiter::new::{{closure}}
             at /home/bbigras/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-0.5.6/src/arbiter.rs:95
fafhrd91 commented 6 years ago

ldap3 library starts its own tokio-core reactor. you should start it in separate thread outside of actix

fafhrd91 commented 6 years ago

re-open if you have more info

phansch commented 6 years ago

Probably related: https://github.com/tokio-rs/tokio-core/issues/319

LyunKi commented 5 years ago

re-open if you have more info

I met the same problem...I want to use actix_web as my web framework , and capnp as the rpc framework,bug when I call the rpc service in the actix.It panic with error message 'cannot recursively call into Core'.I know it may not a bug of actix...bug I am really a noob with rust and tokio framework,and I need some help .

my router (with actix-web-async-await)

        App::new()
            .middleware(Logger::default())
            .resource("/greet/{name}", |r| {
                r.method(Method::GET).with_async(compat(handler::test))
            })

my handler(in my handler , I want to get the result from remote rpc server)

pub async fn test(name: Path<String>) -> Result<impl Responder, Error> {
    let mut core = Core::new().unwrap();
    let handle = core.handle();
    let addr = RPC_ADDRESS
        .to_socket_addrs()
        .unwrap()
        .next()
        .expect("could not parse address");
    let stream = core.run(TcpStream::connect(&addr, &handle)).unwrap();
    stream.set_nodelay(true).unwrap();
    let (reader, writer) = stream.split();
    let rpc_network = Box::new(twoparty::VatNetwork::new(
        reader,
        writer,
        rpc_twoparty_capnp::Side::Client,
        Default::default(),
    ));
    let mut rpc_system = RpcSystem::new(rpc_network, None);
    let greeter_client: greeter::Client = rpc_system.bootstrap(rpc_twoparty_capnp::Side::Server);
    handle.spawn(rpc_system.map_err(|e| eprintln!("failed to run the rpc_system client:{:?}", e)));

    //build request struct
    let mut builder = Builder::new_default();
    let mut request = builder.init_root::<HelloRequest::Builder>();
    request.set_name(&name);

    //set the request param and send the request
    let mut quest = greeter_client.say_hello_request();
    quest.get().set_request(request.into_reader()).unwrap();
    let response = core.run(quest.send().promise).unwrap();
    //receive the response
    let response = response
        .get()
        .expect("failed to get response")
        .get_response()
        .expect("failed to get response content");
    let message = response.get_message().expect("failed to get message");
    Ok(format!(
        "receive a message from {}:{}",
        RPC_ADDRESS, message
    ))
}

is here some method for me to solve this problem...

DoumanAsh commented 5 years ago

@Lynss Don't do own Core in your handler, you should learn more how to work async ecosystem and how to chain futures