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

Panic when calling recv_from() after shutdown() #303

Open
zinid opened this issue Jun 12, 2024 · 0 comments
Open

Panic when calling recv_from() after shutdown() #303

zinid opened this issue Jun 12, 2024 · 0 comments

Comments

@zinid
Copy link

zinid commented Jun 12, 2024

Environment

  • Operating System: Ubuntu 20.04
  • Rust Version: 1.78.0 (9b00956e5 2024-04-29)
  • tokio-uring Version: 0.5.0

Description

A panic occurs when calling recv_from() on a UdpSocket after the socket has been shut down using shutdown(). The error message indicates that an Option::unwrap() is called on a None value within the recv_from method of the tokio-uring library.

Steps to Reproduce

  1. Compile and run the following Rust code using Tokio-Uring:

    use std::net::{Shutdown, SocketAddr};
    use tokio_uring::net::UdpSocket;
    
    fn main() -> Result<(), std::io::Error> {
        tokio_uring::start(async {
            let local_addr: SocketAddr = "0.0.0.0:0".parse().unwrap();
            let socket = UdpSocket::bind(local_addr).await?;
            let buf = vec![0; 8196];
            let _ = socket.shutdown(Shutdown::Both);
            let _ = socket.recv_from(buf).await;
    
            Ok(())
        })
    }
  2. Run the program with cargo run.

Expected Behavior

The program should handle the shutdown state gracefully, either by returning a specific error or by not panicking.

Observed Behavior

The program panics with the following message:

thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-uring-0.5.0/src/io/recv_from.rs:71:55: called `Option::unwrap()` on a `None` value
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

1 participant