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

Temporarily opt out of coop task budgeting #2488

Closed
piscisaureus opened this issue May 4, 2020 · 4 comments
Closed

Temporarily opt out of coop task budgeting #2488

piscisaureus opened this issue May 4, 2020 · 4 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-coop Module: tokio/coop

Comments

@piscisaureus
Copy link

I realize this what I'm going to describe here sounds sketchy, but I really do know what I'm doing, and I've not been able to come up with a different solution.

The request is -- can we have a (unsafe and/or feature-gated as far as I'm concerned) facility to temporarily opt out of coop task budgeting?

  • We have an event loop that under normal circumstances hums along and polls, among other things, V8 (the JavaScript runtime) encapsulated in a Future, and (maybe) a websocket that receives debugger control messages from the chrome inspector.
  • When the user hits pause we'll get a message on the websocket. When that happens we need to poll that debugger websocket only, until the user resumes (or single-steps).
  • This pause state might be entered through a V8 "interrupt" (this is done with a custom Waker - I'll spare you the gory details). That means we cannot return, because that would resume JavaScript execution. So effectively, we have a function that sort of does the same thing as block_on(), and under specific circumstances it needs to poll one specific future only.

This all used to work fine until coop was added. But now, polling the websocket sometimes returns Poll::Pending indefinitely because the task has run out of budget.

So can we have a way to opt out of it for this exceptional circumstance?

@piscisaureus
Copy link
Author

I'm not sure if this helps, but here's an annotated stack trace that hopefully clarifies the problem somewhat:

    deno.exe!tokio::coop::poll_proceed::{{closure}}(tokio::coop::poll_proceed::closure-0 hits, core::cell::Cell<usize> *) Line 228 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\coop.rs:228)
^^ Hitting the coop task budget ceiling ^^
    deno.exe!std::thread::local::LocalKey<core::cell::Cell<usize>>::try_with<core::cell::Cell<usize>,closure-0,core::task::poll::Poll<()>>(tokio::coop::poll_proceed::closure-0 self) Line 262 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:262)
    deno.exe!std::thread::local::LocalKey<core::cell::Cell<usize>>::with<core::cell::Cell<usize>,closure-0,core::task::poll::Poll<()>>(tokio::coop::poll_proceed::closure-0 self) Line 239 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:239)
    deno.exe!tokio::coop::poll_proceed(core::task::wake::Context * cx) Line 226 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\coop.rs:226)
    deno.exe!tokio::io::registration::Registration::poll_read_ready(core::task::wake::Context * self) Line 143 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\io\registration.rs:143)
    deno.exe!tokio::io::poll_evented::PollEvented<mio::net::tcp::TcpStream>::poll_read_ready<mio::net::tcp::TcpStream>(core::task::wake::Context * self, mio::event_imp::Ready cx) Line 247 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\io\poll_evented.rs:247)
    deno.exe!tokio::net::tcp::stream::TcpStream::poll_read_priv(core::task::wake::Context * self, mut slice<u8>* cx) Line 637 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\net\tcp\stream.rs:637)
    deno.exe!tokio::net::tcp::stream::{{impl}}::poll_read(core::pin::Pin<mut tokio::net::tcp::stream::TcpStream*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 807 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\net\tcp\stream.rs:807)
    deno.exe!hyper::server::tcp::addr_stream::{{impl}}::poll_read(core::pin::Pin<mut hyper::server::tcp::addr_stream::AddrStream*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 254 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\hyper-0.13.4\src\server\tcp.rs:254)
    deno.exe!hyper::upgrade::{{impl}}::poll_read<hyper::server::tcp::addr_stream::AddrStream>(core::pin::Pin<mut hyper::upgrade::ForwardsWriteBuf<hyper::server::tcp::addr_stream::AddrStream>*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 260 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\hyper-0.13.4\src\upgrade.rs:260)
    deno.exe!tokio::io::async_read::{{impl}}::poll_read<Io>(core::pin::Pin<mut alloc::boxed::Box<Io>*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 147 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\io\async_read.rs:147)
    deno.exe!hyper::common::io::rewind::{{impl}}::poll_read<alloc::boxed::Box<Io>>(core::pin::Pin<mut hyper::common::io::rewind::Rewind<alloc::boxed::Box<Io>>*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 73 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\hyper-0.13.4\src\common\io\rewind.rs:73)
    deno.exe!hyper::upgrade::{{impl}}::poll_read(core::pin::Pin<mut hyper::upgrade::Upgraded*> self, core::task::wake::Context * cx, mut slice<u8>* buf) Line 118 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\hyper-0.13.4\src\upgrade.rs:118)
    deno.exe!tokio_tungstenite::compat::{{impl}}::read::{{closure}}<hyper::upgrade::Upgraded>(tokio_tungstenite::compat::{{impl}}::read::closure-0 ctx, core::task::wake::Context * stream, core::pin::Pin<mut hyper::upgrade::Upgraded*>) Line 155 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-tungstenite-0.10.1\src\compat.rs:155)
    deno.exe!tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>::with_context<hyper::upgrade::Upgraded,closure-0,usize>(tokio_tungstenite::compat::ContextWaker self, tokio_tungstenite::compat::{{impl}}::read::closure-0 kind) Line 130 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-tungstenite-0.10.1\src\compat.rs:130)
    deno.exe!tokio_tungstenite::compat::{{impl}}::read<hyper::upgrade::Upgraded>(tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded> * self, mut slice<u8>* buf) Line 156 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-tungstenite-0.10.1\src\compat.rs:156)
    deno.exe!input_buffer::DoRead::read_from<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>(input_buffer::DoRead self, tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded> * stream) Line 170 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\input_buffer-0.3.1\src\lib.rs:170)
    deno.exe!tungstenite::protocol::frame::FrameCodec::read_frame<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>(tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded> * self, core::option::Option<usize> stream) Line 161 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tungstenite-0.10.1\src\protocol\frame\mod.rs:161)
    deno.exe!tungstenite::protocol::WebSocketContext::read_message_frame<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>(tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded> * self) Line 411 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tungstenite-0.10.1\src\protocol\mod.rs:411)
    deno.exe!tungstenite::protocol::WebSocketContext::read_message<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>(tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded> * self) Line 289 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tungstenite-0.10.1\src\protocol\mod.rs:289)
    deno.exe!tungstenite::protocol::WebSocket<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>::read_message<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>>() Line 147 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tungstenite-0.10.1\src\protocol\mod.rs:147)
    deno.exe!tokio_tungstenite::{{impl}}::poll_next::{{closure}}<hyper::upgrade::Upgraded>(tokio_tungstenite::{{impl}}::poll_next::closure-0, tungstenite::protocol::WebSocket<tokio_tungstenite::compat::AllowStd<hyper::upgrade::Upgraded>> * s) Line 268 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-tungstenite-0.10.1\src\lib.rs:268)
    deno.exe!tokio_tungstenite::WebSocketStream<hyper::upgrade::Upgraded>::with_context<hyper::upgrade::Upgraded,closure-0,core::task::poll::Poll<core::result::Result<tungstenite::protocol::message::Message, tungstenite::error::Error>>>(core::option::Option<(tokio_tungstenite::compat::ContextWaker, mut core::task::wake::Context*)> self, tokio_tungstenite::{{impl}}::poll_next::closure-0 ctx) Line 225 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-tungstenite-0.10.1\src\lib.rs:225)
    deno.exe!tokio_tungstenite::{{impl}}::poll_next<hyper::upgrade::Upgraded>(core::pin::Pin<mut tokio_tungstenite::WebSocketStream<hyper::upgrade::Upgraded>*> self, core::task::wake::Context * cx) Line 4 (<::futures_core::task::poll::ready macros>:4)
    deno.exe!warp::filters::ws::{{impl}}::poll_next(core::pin::Pin<mut warp::filters::ws::WebSocket*> self, core::task::wake::Context * cx) Line 184 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\warp-0.2.2\src\filters\ws.rs:184)
    deno.exe!futures_util::stream::stream::split::{{impl}}::poll_next<warp::filters::ws::WebSocket>(core::pin::Pin<mut futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>*> self, core::task::wake::Context * cx) Line 31 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\stream\stream\split.rs:31)
    deno.exe!futures_core::stream::{{impl}}::try_poll_next<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>,warp::filters::ws::Message,warp::error::Error>(core::pin::Pin<mut futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>*> self, core::task::wake::Context * cx) Line 194 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-core-0.3.4\src\stream.rs:194)
    deno.exe!futures_util::stream::try_stream::map_ok::{{impl}}::poll_next<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>,closure-0,()>(core::pin::Pin<mut futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>*> self, core::task::wake::Context * cx) Line 95 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\stream\try_stream\map_ok.rs:95)
    deno.exe!futures_core::stream::{{impl}}::try_poll_next<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>,(),warp::error::Error>(core::pin::Pin<mut futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>*> self, core::task::wake::Context * cx) Line 194 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-core-0.3.4\src\stream.rs:194)
    deno.exe!futures_util::stream::try_stream::try_collect::{{impl}}::poll<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>,()>(core::pin::Pin<mut futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>*> self, core::task::wake::Context * cx) Line 56 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\stream\try_stream\try_collect.rs:56)
    deno.exe!futures_core::future::{{impl}}::try_poll<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>,(),warp::error::Error>(core::pin::Pin<mut futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>*> self, core::task::wake::Context * cx) Line 84 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-core-0.3.4\src\future.rs:84)
    deno.exe!futures_util::future::try_future::into_future::{{impl}}::poll<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>>(core::pin::Pin<mut futures_util::future::try_future::into_future::IntoFuture<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>>*> self, core::task::wake::Context * cx) Line 35 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\future\try_future\into_future.rs:35)
    deno.exe!futures_util::future::maybe_done::{{impl}}::poll<futures_util::future::try_future::into_future::IntoFuture<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>>>(core::pin::Pin<mut futures_util::future::maybe_done::MaybeDone<futures_util::future::try_future::into_future::IntoFuture<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>>>*> self, core::task::wake::Context * cx) Line 4 (<::futures_core::task::poll::ready macros>:4)
    deno.exe!futures_util::future::try_join::{{impl}}::poll<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>,futures_util::stream::stream::forward::Forward<futures_util::stream::stream::map::Map<futures_channel::mpsc::UnboundedReceiver<rusty_v8::support::UniquePtr<rusty_v8::inspector::StringBuffer>>, closure-1>, futures_util::stream::stream::split::SplitSink<warp::filters::ws::WebSocket, warp::filters::ws::Message>>>(core::pin::Pin<mut futures_util::future::try_join::TryJoin<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>, futures_util::stream::stream::forward::Forward<futures_util::stream::stream::map::Map<futures_channel::mpsc::UnboundedReceiver<rusty_v8::support::UniquePtr<rusty_v8::inspector::StringBuffer>>, closure-1>, futures_util::stream::stream::split::SplitSink<warp::filters::ws::WebSocket, warp::filters::ws::Message>>>*> self, core::task::wake::Context * cx) Line 74 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\future\try_join.rs:74)
    deno.exe!std::future::poll_with_tls_context<futures_util::future::try_join::TryJoin<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>, futures_util::stream::stream::forward::Forward<futures_util::stream::stream::map::Map<futures_channel::mpsc::UnboundedReceiver<rusty_v8::support::UniquePtr<rusty_v8::inspector::StringBuffer>>, closure-1>, futures_util::stream::stream::split::SplitSink<warp::filters::ws::WebSocket, warp::filters::ws::Message>>>>(core::pin::Pin<mut futures_util::future::try_join::TryJoin<futures_util::stream::try_stream::try_collect::TryCollect<futures_util::stream::try_stream::map_ok::MapOk<futures_util::stream::stream::split::SplitStream<warp::filters::ws::WebSocket>, closure-0>, ()>, futures_util::stream::stream::forward::Forward<futures_util::stream::stream::map::Map<futures_channel::mpsc::UnboundedReceiver<rusty_v8::support::UniquePtr<rusty_v8::inspector::StringBuffer>>, closure-1>, futures_util::stream::stream::split::SplitSink<warp::filters::ws::WebSocket, warp::filters::ws::Message>>>*> f) Line 102 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\future.rs:102)
^^ We're trying to poll the debugger websocket(s) ONLY ^^
    deno.exe!deno::inspector::{{impl}}::create_message_handler::{{closure}}(core::pin::Pin<mut generator-2*>) Line 698 (d:\deno\cli\inspector.rs:698)
    deno.exe!std::future::{{impl}}::poll<generator-2>(core::pin::Pin<mut std::future::GenFuture<generator-2>*> self, core::task::wake::Context * cx) Line 44 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\future.rs:44)
    deno.exe!core::future::future::{{impl}}::poll<alloc::boxed::Box<Future>>(core::pin::Pin<mut core::pin::Pin<alloc::boxed::Box<Future>>*> self, core::task::wake::Context * cx) Line 118 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcore\future\future.rs:118)
    deno.exe!futures_util::future::future::FutureExt::poll_unpin<core::pin::Pin<alloc::boxed::Box<Future>>>(core::pin::Pin<alloc::boxed::Box<Future>> * self, core::task::wake::Context * cx) Line 507 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\future\future\mod.rs:507)
    deno.exe!deno::inspector::{{impl}}::poll(core::pin::Pin<mut deno::inspector::DenoInspectorSession*> self, core::task::wake::Context * cx) Line 743 (d:\deno\cli\inspector.rs:743)
    deno.exe!alloc::boxed::{{impl}}::poll<deno::inspector::DenoInspectorSession>(core::pin::Pin<mut alloc::boxed::Box<deno::inspector::DenoInspectorSession>*> self, core::task::wake::Context * cx) Line 1157 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\liballoc\boxed.rs:1157)
    deno.exe!futures_util::stream::futures_unordered::{{impl}}::poll_next<alloc::boxed::Box<deno::inspector::DenoInspectorSession>>(core::pin::Pin<mut futures_util::stream::futures_unordered::FuturesUnordered<alloc::boxed::Box<deno::inspector::DenoInspectorSession>>*> self, core::task::wake::Context * cx) Line 544 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\stream\futures_unordered\mod.rs:544)
    deno.exe!futures_util::stream::stream::StreamExt::poll_next_unpin<futures_util::stream::futures_unordered::FuturesUnordered<alloc::boxed::Box<deno::inspector::DenoInspectorSession>>>(futures_util::stream::futures_unordered::FuturesUnordered<alloc::boxed::Box<deno::inspector::DenoInspectorSession>> * self, core::task::wake::Context * cx) Line 1184 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\futures-util-0.3.4\src\stream\stream\mod.rs:1184)
    deno.exe!deno::inspector::DenoInspector::poll_sessions(core::option::Option<mut core::task::wake::Context*> self) Line 433 (d:\deno\cli\inspector.rs:433)
    deno.exe!deno::inspector::{{impl}}::wake_by_ref::{{closure}}::handle_interrupt(rusty_v8::isolate::Isolate * _isolate, core::ffi::c_void * arg) Line 594 (d:\deno\cli\inspector.rs:594)
^^ JavaScript execution was interrupted and V8 called our interrupt callback ^^
    deno.exe!v8::internal::Isolate::InvokeApiInterruptCallbacks() Line 1412 (c:\Users\me\v8\src\execution\isolate.cc:1412)
    deno.exe!v8::internal::StackGuard::HandleInterrupts() Line 297 (c:\Users\me\v8\src\execution\stack-guard.cc:297)
    deno.exe!v8::internal::Runtime_StackGuardWithGap() Line 287 (c:\Users\me\v8\src\runtime\runtime-internal.cc:287)
    deno.exe!Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit() (Unknown Source:0)
    000003a8000ca0cb() (Unknown Source:0)
    deno.exe!Builtins_JSConstructStubGeneric() (Unknown Source:0)
    000003a8000c8f58() (Unknown Source:0)
    deno.exe!Builtins_InterpreterEntryTrampoline() (Unknown Source:0)
    deno.exe!Builtins_GeneratorPrototypeNext() (Unknown Source:0)
    deno.exe!Builtins_JSEntryTrampoline() (Unknown Source:0)
    deno.exe!Builtins_JSEntry() (Unknown Source:0)
    deno.exe!v8::internal::`anonymous namespace'::Invoke() Line 367 (c:\Users\me\v8\src\execution\execution.cc:367)
    deno.exe!v8::internal::`anonymous namespace'::InvokeWithTryCatch() Line 427 (c:\Users\me\v8\src\execution\execution.cc:427)
    deno.exe!v8::internal::Execution::TryCall() Line 494 (c:\Users\me\v8\src\execution\execution.cc:494)
    deno.exe!v8::internal::SourceTextModule::ExecuteModule() Line 933 (c:\Users\me\v8\src\objects\source-text-module.cc:933)
    deno.exe!v8::internal::SourceTextModule::InnerModuleEvaluation() Line 1088 (c:\Users\me\v8\src\objects\source-text-module.cc:1088)
    deno.exe!v8::internal::SourceTextModule::Evaluate() Line 677 (c:\Users\me\v8\src\objects\source-text-module.cc:677)
    deno.exe!v8::internal::SourceTextModule::EvaluateMaybeAsync() Line 631 (c:\Users\me\v8\src\objects\source-text-module.cc:631)
    deno.exe!v8::internal::Module::Evaluate() Line 258 (c:\Users\me\v8\src\objects\module.cc:258)
    deno.exe!v8::Module::Evaluate() Line 2387 (c:\Users\me\v8\src\api\api.cc:2387)
^^ Entered the V8 virtual machine here ^^
    deno.exe!v8__Module__Evaluate() Line 1659 (c:\Users\me\src\binding.cc:1659)
    deno.exe!rusty_v8::data::Module::evaluate<rusty_v8::scope::Entered<rusty_v8::scope::ContextScope, rusty_v8::scope::Entered<rusty_v8::handle_scope::HandleScope, rusty_v8::isolate::OwnedIsolate>>>(rusty_v8::scope::Entered<rusty_v8::scope::ContextScope, rusty_v8::scope::Entered<rusty_v8::handle_scope::HandleScope, rusty_v8::isolate::OwnedIsolate>> * self, rusty_v8::local::Local<rusty_v8::data::Context> scope) Line 216 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\rusty_v8-0.4.0\src\module.rs:216)
    deno.exe!deno_core::es_isolate::EsIsolate::mod_evaluate(int self) Line 257 (d:\deno\core\es_isolate.rs:257)
    deno.exe!deno::worker::{{impl}}::execute_module::{{closure}}(core::pin::Pin<mut generator-0*>) Line 166 (d:\deno\cli\worker.rs:166)
    deno.exe!std::future::{{impl}}::poll<generator-0>(core::pin::Pin<mut std::future::GenFuture<generator-0>*> self, core::task::wake::Context * cx) Line 44 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\future.rs:44)
    deno.exe!std::future::poll_with_tls_context<std::future::GenFuture<generator-0>>(core::pin::Pin<mut std::future::GenFuture<generator-0>*> f) Line 102 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\future.rs:102)
    deno.exe!deno::run_command::{{closure}}(core::pin::Pin<mut generator-0*>) Line 475 (d:\deno\cli\lib.rs:475)
    deno.exe!std::future::{{impl}}::poll<generator-0>(core::pin::Pin<mut std::future::GenFuture<generator-0>*> self, core::task::wake::Context * cx) Line 44 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\future.rs:44)
    deno.exe!core::future::future::{{impl}}::poll<alloc::boxed::Box<Future>>(core::pin::Pin<mut core::pin::Pin<alloc::boxed::Box<Future>>*> self, core::task::wake::Context * cx) Line 119 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcore\future\future.rs:119)
    deno.exe!tokio::runtime::basic_scheduler::{{impl}}::block_on::{{closure}}::{{closure}}<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>,core::pin::Pin<alloc::boxed::Box<Future>>>(tokio::runtime::basic_scheduler::{{impl}}::block_on::{{closure}}::closure-0) Line 131 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\basic_scheduler.rs:131)
    deno.exe!tokio::coop::budget::{{closure}}<closure-0,core::task::poll::Poll<core::result::Result<(), deno_core::any_error::ErrBox>>>(tokio::coop::budget::closure-0 hits, core::cell::Cell<usize> *) Line 97 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\coop.rs:97)
    deno.exe!std::thread::local::LocalKey<core::cell::Cell<usize>>::try_with<core::cell::Cell<usize>,closure-0,core::task::poll::Poll<core::result::Result<(), deno_core::any_error::ErrBox>>>(tokio::coop::budget::closure-0 self) Line 262 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:262)
    deno.exe!std::thread::local::LocalKey<core::cell::Cell<usize>>::with<core::cell::Cell<usize>,closure-0,core::task::poll::Poll<core::result::Result<(), deno_core::any_error::ErrBox>>>(tokio::coop::budget::closure-0 self) Line 239 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\thread\local.rs:239)
    [Inline Frame] deno.exe!tokio::coop::budget(tokio::runtime::basic_scheduler::{{impl}}::block_on::{{closure}}::closure-0 f) Line 79 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\coop.rs:79)
    deno.exe!tokio::runtime::basic_scheduler::{{impl}}::block_on::{{closure}}<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>,core::pin::Pin<alloc::boxed::Box<Future>>>(tokio::runtime::basic_scheduler::{{impl}}::block_on::closure-0 scheduler, tokio::runtime::basic_scheduler::BasicScheduler<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>> * context, tokio::runtime::basic_scheduler::Context *) Line 131 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\basic_scheduler.rs:131)
    deno.exe!tokio::runtime::basic_scheduler::enter::{{closure}}<closure-0,core::result::Result<(), deno_core::any_error::ErrBox>,tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>>(tokio::runtime::basic_scheduler::enter::closure-0) Line 213 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\basic_scheduler.rs:213)
    deno.exe!tokio::macros::scoped_tls::ScopedKey<tokio::runtime::basic_scheduler::Context>::set<tokio::runtime::basic_scheduler::Context,closure-0,core::result::Result<(), deno_core::any_error::ErrBox>>(tokio::runtime::basic_scheduler::Context * self, tokio::runtime::basic_scheduler::enter::closure-0 t) Line 64 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\macros\scoped_tls.rs:64)
    deno.exe!tokio::runtime::basic_scheduler::enter<closure-0,core::result::Result<(), deno_core::any_error::ErrBox>,tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>>(tokio::runtime::basic_scheduler::BasicScheduler<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>> * scheduler, tokio::runtime::basic_scheduler::{{impl}}::block_on::closure-0 f) Line 213 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\basic_scheduler.rs:213)
    deno.exe!tokio::runtime::basic_scheduler::BasicScheduler<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>>::block_on<tokio::park::either::Either<tokio::time::driver::Driver<tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>, tokio::park::either::Either<tokio::io::driver::Driver, tokio::park::thread::ParkThread>>,core::pin::Pin<alloc::boxed::Box<Future>>>(core::pin::Pin<alloc::boxed::Box<Future>> self) Line 123 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\basic_scheduler.rs:123)
    deno.exe!tokio::runtime::{{impl}}::block_on::{{closure}}<core::pin::Pin<alloc::boxed::Box<Future>>>(tokio::runtime::{{impl}}::block_on::closure-0) Line 418 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\mod.rs:418)
    deno.exe!tokio::runtime::context::enter<closure-0,core::result::Result<(), deno_core::any_error::ErrBox>>(tokio::runtime::handle::Handle new, tokio::runtime::{{impl}}::block_on::closure-0 f) Line 72 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\context.rs:72)
    deno.exe!tokio::runtime::handle::Handle::enter<closure-0,core::result::Result<(), deno_core::any_error::ErrBox>>(tokio::runtime::{{impl}}::block_on::closure-0 self) Line 39 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\handle.rs:39)
    deno.exe!tokio::runtime::Runtime::block_on<core::pin::Pin<alloc::boxed::Box<Future>>>(core::pin::Pin<alloc::boxed::Box<Future>> self) Line 415 (c:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.2.18\src\runtime\mod.rs:415)
^^ Entered the Tokio runtime here for the first time ^^
    deno.exe!deno::tokio_util::run_basic<core::pin::Pin<alloc::boxed::Box<Future>>,core::result::Result<(), deno_core::any_error::ErrBox>>(core::pin::Pin<alloc::boxed::Box<Future>> future) Line 18 (d:\deno\cli\tokio_util.rs:18)
    deno.exe!deno::main() Line 625 (d:\deno\cli\lib.rs:625)
    deno.exe!deno::main() Line 5 (d:\deno\cli\main.rs:5)
    deno.exe!std::rt::lang_start::{{closure}}<()>(std::rt::lang_start::closure-0 *) Line 67 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:67)
    [Inline Frame] deno.exe!std::rt::lang_start_internal::{{closure}}() Line 52 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:52)
    deno.exe!std::panicking::try::do_call<closure-0,i32>() Line 303 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:303)
    deno.exe!panic_unwind::__rust_maybe_catch_panic() Line 94 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libpanic_unwind\lib.rs:94)
    [Inline Frame] deno.exe!std::panicking::try() Line 281 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panicking.rs:281)
    [Inline Frame] deno.exe!std::panic::catch_unwind() Line 394 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\panic.rs:394)
    deno.exe!std::rt::lang_start_internal() Line 51 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:51)
    deno.exe!std::rt::lang_start<()>(void(*)() main, __int64 argc, unsigned char * * argv) Line 67 (c:\Users\me\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd\rt.rs:67)
    deno.exe!main() (Unknown Source:0)
    [Inline Frame] deno.exe!invoke_main() Line 78 (d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78)
    deno.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
    kernel32.dll!BaseThreadInitThunk() (Unknown Source:0)
    ntdll.dll!RtlUserThreadStart() (Unknown Source:0)
^^ Thread entry point. ^^

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-coop Module: tokio/coop labels May 4, 2020
@carllerche
Copy link
Member

I remember we discussed this some over Discord and we had a strategy... but now I forgot what it was.

#2711 disables coop budgeting when in block_in_place. That might work for you? Not sure.

@piscisaureus
Copy link
Author

We did find a different workaround, using a different thread and a pair of unbounded std channels.

#2711 disables coop budgeting when in block_in_place

Yeah that's what we would have needed.
Except we're using the basic RT and as we all know, block_in_place...

@piscisaureus
Copy link
Author

piscisaureus commented Jul 29, 2020

Closing - I have no need for this any more and if I did I'd now open an issue requesting unsafe recursive block_on().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-coop Module: tokio/coop
Projects
None yet
Development

No branches or pull requests

3 participants