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

Call stack overflows when turning Future to Promise #963

Closed
Procrat opened this issue Oct 14, 2018 · 3 comments
Closed

Call stack overflows when turning Future to Promise #963

Procrat opened this issue Oct 14, 2018 · 3 comments

Comments

@Procrat
Copy link

Procrat commented Oct 14, 2018

Since I updated some dependencies, whenever I try to execute some promises that were converted from Futures, I've been getting this error:

RangeError: Maximum call stack size exceeded
    at _$LT$core..ptr..NonNull$LT$T$GT$$GT$::as_ref::hf8309c7a13699825 (wasm-function[5481]:0)
    at _$LT$core..task..wake..Waker$u20$as$u20$core..clone..Clone$GT$::clone::h989e9a814b8077db (wasm-function[5015]:51)
    at futures_util::compat::compat01to03::_$LT$impl$u20$core..convert..From$LT$futures_util..compat..compat01to03..WakerToHandle$LT$$u27$a$GT$$GT$$u20$for$u20$futures..task_impl..NotifyHandle$GT$::from::h90b2ad3820969d25 (wasm-function[4998]:51)
    at _$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$::into::hfebb192212912f19 (wasm-function[5047]:40)
    at futures::task_impl::with_notify::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h52050cf89d8b1dbc (wasm-function[629]:61)
    at futures::task_impl::core::BorrowedUnpark::to_owned::hd2a59147c15989b3 (wasm-function[5202]:63)
    at futures::task_impl::std::BorrowedUnpark::to_owned::hc08356360e18165b (wasm-function[5164]:233)
    at futures::task_impl::current::_$u7b$$u7b$closure$u7d$$u7d$::h2814a97caa81de28 (wasm-function[5210]:95)
    at futures::task_impl::with::hec4af1d18f0fd517 (wasm-function[5209]:203)
    at futures::task_impl::current::hd4b0d5d7d1293194 (wasm-function[5211]:24)
    at _$LT$futures_util..compat..compat03to01..CurrentRef$u20$as$u20$core..task..wake..UnsafeWake$GT$::clone_raw::h05954536c0e3cd75 (wasm-function[5000]:63)
    at _$LT$core..task..wake..Waker$u20$as$u20$core..clone..Clone$GT$::clone::h989e9a814b8077db (wasm-function[5015]:92)
    at futures_util::compat::compat01to03::_$LT$impl$u20$core..convert..From$LT$futures_util..compat..compat01to03..WakerToHandle$LT$$u27$a$GT$$GT$$u20$for$u20$futures..task_impl..NotifyHandle$GT$::from::h90b2ad3820969d25 (wasm-function[4998]:51)
    at _$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$::into::hfebb192212912f19 (wasm-function[5047]:40)
    at futures::task_impl::with_notify::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h52050cf89d8b1dbc (wasm-function[629]:61)
    at futures::task_impl::core::BorrowedUnpark::to_owned::hd2a59147c15989b3 (wasm-function[5202]:63)
    at futures::task_impl::std::BorrowedUnpark::to_owned::hc08356360e18165b (wasm-function[5164]:233)
    at futures::task_impl::current::_$u7b$$u7b$closure$u7d$$u7d$::h2814a97caa81de28 (wasm-function[5210]:95)
    at futures::task_impl::with::hec4af1d18f0fd517 (wasm-function[5209]:203)
    at futures::task_impl::current::hd4b0d5d7d1293194 (wasm-function[5211]:24)
    at _$LT$futures_util..compat..compat03to01..CurrentRef$u20$as$u20$core..task..wake..UnsafeWake$GT$::clone_raw::h05954536c0e3cd75 (wasm-function[5000]:63)
    at _$LT$core..task..wake..Waker$u20$as$u20$core..clone..Clone$GT$::clone::h989e9a814b8077db (wasm-function[5015]:92)
    at futures_util::compat::compat01to03::_$LT$impl$u20$core..convert..From$LT$futures_util..compat..compat01to03..WakerToHandle$LT$$u27$a$GT$$GT$$u20$for$u20$futures..task_impl..NotifyHandle$GT$::from::h90b2ad3820969d25 (wasm-function[4998]:51)
    at _$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$::into::hfebb192212912f19 (wasm-function[5047]:40)
    at futures::task_impl::with_notify::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h52050cf89d8b1dbc (wasm-function[629]:61)
    at futures::task_impl::core::BorrowedUnpark::to_owned::hd2a59147c15989b3 (wasm-function[5202]:63)
    at futures::task_impl::std::BorrowedUnpark::to_owned::hc08356360e18165b (wasm-function[5164]:233)
    at futures::task_impl::current::_$u7b$$u7b$closure$u7d$$u7d$::h2814a97caa81de28 (wasm-function[5210]:95)
    at futures::task_impl::with::hec4af1d18f0fd517 (wasm-function[5209]:203)
    at futures::task_impl::current::hd4b0d5d7d1293194 (wasm-function[5211]:24)
    at _$LT$futures_util..compat..compat03to01..CurrentRef$u20$as$u20$core..task..wake..UnsafeWake$GT$::clone_raw::h05954536c0e3cd75 (wasm-function[5000]:63)
    at _$LT$core..task..wake..Waker$u20$as$u20$core..clone..Clone$GT$::clone::h989e9a814b8077db (wasm-function[5015]:92)
    at futures_util::compat::compat01to03::_$LT$impl$u20$core..convert..From$LT$futures_util..compat..compat01to03..WakerToHandle$LT$$u27$a$GT$$GT$$u20$for$u20$futures..task_impl..NotifyHandle$GT$::from::h90b2ad3820969d25 (wasm-function[4998]:51)
    at _$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$::into::hfebb192212912f19 (wasm-function[5047]:40)
    at futures::task_impl::with_notify::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h52050cf89d8b1dbc (wasm-function[629]:61)
    (...snip...)

I'm not entirely certain, but the stack trace makes me suspect that this isn't directly the fault of my part of the code. On the other hand, I've read in the documentation that "if the future provided panics then the returned Promise will not resolve", so I'm guessing that is what is going wrong here.

I was under the impression that #954 would fix this, or would rather somehow expose what the panic was, or at least change something, but that didn't seem the case.

Apart from this issue, does anyone have an idea on how to discover what is actually panicking here?

@alexcrichton
Copy link
Contributor

Oh dear, this sounds bad! I would have also assumed that #954 would fix this. Do you have some sample code that reproduces this that I could help debug with? Other than #954 I'm not sure what could be going on here...

@Procrat
Copy link
Author

Procrat commented Oct 15, 2018

I didn't really give much information, did I?

In hindsight, I don't know why I posted this issue on this tracker actually. Things could be going wrong on any of these levels:

  • I'm converting promises to 3.0 futures,
  • then turning those to 1.0 futures (which is required by wasm-bindgen-futures at the moment),
  • then turning those back to promises,
  • to eventually run them from JavaScript.

I didn't think of the second step as potentially causing the problem. However, in the meantime, I have discovered rust-lang/futures-rs#1283 and seeing that the compatibility layer is mentioned in the recurring stack trace I posted, I'm going to assume for now that that is what causing this issue.

I'll try to come up with a minimal example and see if rust-lang/futures-rs#1286 fixes it. Thanks for your help. :-) I think you can close this and if it would appear that the problem isn't caused by that bug in the futures compat layer, I'll reopen this issue.

@alexcrichton
Copy link
Contributor

Ok cool sounds good to me, thanks for the continued investigation! If this does end up being in wasm-bindgen though just lemme know and I'll reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants