-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
net: Consider having from_std
panic on blocking sockets
#7172
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
Labels
A-tokio
Area: The main tokio crate
C-proposal
Category: a proposal and request for comments
M-net
Module: tokio/net
S-breaking-change
A breaking change that requires manual coordination to be released.
Comments
Noah-Kennedy
added a commit
that referenced
this issue
Mar 5, 2025
5 tasks
bkirwi
added a commit
to MaterializeInc/materialize
that referenced
this issue
Mar 19, 2025
### Motivation Testdrive started failing for me locally due to this Tokio behaviour change: tokio-rs/tokio#7172 ~I'm unsure why this doesn't fail in CI... maybe a MacOS thing?~ I believe this is happening locally because I'm running the code in debug mode, and these assertions are debug-only for now. Anyways setting the option makes things work as expected.
When I used |
jonhoo
added a commit
to jonhoo/async-bincode
that referenced
this issue
Mar 22, 2025
lyuts
added a commit
to lyuts/net-route
that referenced
this issue
Apr 9, 2025
The latest upstream code is failing on macos at runtime with the following error: ``` Registering a blocking socket with the tokio runtime is unsupported. If you wish to do anyways, please add `--cfg tokio_allow_from_blocking_fd` to your RUSTFLAGS. See github.com/tokio-rs/tokio/issues/7172 for details. ``` Ref: https://github.com/tokio-rs/tokio/blob/master/tokio/src/util/blocking_check.rs#L12-L17 This change is similar to johnyburd#22 which fixed the issue for the route listener, but it doesn't solve the issue for add/delete methods because they end up creating their own UnixStream. Minimal reproducible sample ```rust use net_route::{Handle, Route}; async fn main() { let handle = Handle::new().unwrap(); let route = Route::new("10.11.12.13".parse().unwrap(), 32); handle.add(&route).await; } ```
nyetwurk
added a commit
to Blockdaemon/agave-snapshot-gossip-client
that referenced
this issue
Apr 14, 2025
Fix error re: non-blocking and using from_std on a std TcpListener by setting it non-blocking In debug mode: thread 'main' panicked at src/ip_echo.rs:128:32: Registering a blocking socket with the tokio runtime is unsupported. If you wish to do anyways, please add `--cfg tokio_allow_from_blocking_fd` to your RUSTFLAGS. See github.com/tokio-rs/tokio/issues/7172 for details.
2 tasks
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-proposal
Category: a proposal and request for comments
M-net
Module: tokio/net
S-breaking-change
A breaking change that requires manual coordination to be released.
While Tokio technically accepts and can function using blocking sockets, it usually results in poor and unexpected runtime behaviors. There is most likely no good reason to pass a blocking socket to
from_std
. Accidentally passing blocking sockets tofrom_std
is a common error that results in hard-to-debug runtime behaviors.Because Tokio has historically technically accepted blocking sockets to be passed to
from_std,
changing the behavior to panic on blocking sockets could be considered a breaking change. We are considering making that change anyway because we are not aware of any valid usage.As a first step, we changed Tokio to panic when passing a blocking socket to
from_std
and debug assertions are enabled. Use thetokio_allow_from_blocking_fd
cfg flag to disable this assertion.If you have a valid use case for passing blocking sockets to
from_std
, please comment in this thread.The text was updated successfully, but these errors were encountered: