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

Box futures passed to block_on in debug mode #6673

Closed
ibraheemdev opened this issue Jul 6, 2024 · 2 comments · Fixed by #6692
Closed

Box futures passed to block_on in debug mode #6673

ibraheemdev opened this issue Jul 6, 2024 · 2 comments · Fixed by #6692
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-task Module: tokio/task

Comments

@ibraheemdev
Copy link
Contributor

Tokio currently does this in spawn but not block_on. For large async main functions this can lead to stack overflows in debug mode, especially on Windows. See astral-sh/uv#4851 for example.

@ibraheemdev ibraheemdev added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Jul 6, 2024
@Darksonn Darksonn added the M-task Module: tokio/task label Jul 7, 2024
@mox692
Copy link
Member

mox692 commented Jul 8, 2024

I think we can add similar checks for block_on as well.

@Darksonn
Do you have a better idea other than just adding Future's size check logic like #4009? (I'm wondering since it seems that you said such a possibility in that PR.)

@Darksonn
Copy link
Contributor

There are some other approaches, but they are more complicated. Basically, the idea is to avoid passing the future by ownership through many function calls. Instead, you create a kind of owned pointer that references the future object on the stack, and then you pass the pointer all the way down to the function that moves it to the heap.

But I'm happy to add a size check for now.

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-task Module: tokio/task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants