Skip to content

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

Open
@zinid

Description

@zinid

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions