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 on setting idle_connection_timeout() of SwarmBuilder with max value #4555

Closed
pawanl1x opened this issue Sep 25, 2023 · 7 comments · Fixed by #4559
Closed

Panic on setting idle_connection_timeout() of SwarmBuilder with max value #4555

pawanl1x opened this issue Sep 25, 2023 · 7 comments · Fixed by #4559

Comments

@pawanl1x
Copy link

pawanl1x commented Sep 25, 2023

Summary

Progam is panicking after setting the idle_connection_timeout(Duration::from_secs(u64::MAX)) in SwarmBuilder.

Expected behaviour

Actual behaviour

thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33

Possible Solution

Version

  • libp2p version (version number, commit, or branch):

Would you like to work on fixing this bug?

Yes / No / Maybe.

@thomaseizinger

This comment was marked as outdated.

@pawanl1x
Copy link
Author

Okay, just noticed on thing.

For the fist one, initially got a panic error but the program terminated with the same error as second one.

Stacktrace:

pawan@Pawans-MacBook-Pro-2 chat % RUST_LOG=debug cargo run
   Compiling chat-example v0.1.0 (/Users/pawan/Desktop/blockchain/rust-libp2p/examples/chat)
warning: unused import: `async_std::task::sleep`
  --> examples/chat/src/main.rs:36:5
   |
36 | use async_std::task::sleep;
   |     ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `chat-example` (bin "chat-example") generated 1 warning (run `cargo fix --bin "chat-example"` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 2.77s
     Running `/Users/pawan/Desktop/blockchain/rust-libp2p/target/debug/chat-example`
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Subscribing to topic: test-net
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Running JOIN for topic: TopicHash { hash: "test-net" }
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] RANDOM PEERS: Got 0 peers
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] JOIN: Inserting 0 random peers into the mesh
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Completed JOIN for topic: TopicHash { hash: "test-net" }
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Subscribed to topic: test-net
[2023-09-25T12:29:52Z INFO  libp2p_swarm] Local peer id: 12D3KooWHKqLDP6kKoRNbtQS4us6W6dsNFnLB7XNB8sSe4Mzi5sG
[2023-09-25T12:29:52Z DEBUG libp2p_core::transport::choice] Failed to listen on /ip4/0.0.0.0/tcp/0 using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] listening on 0.0.0.0:0
Enter messages via STDIN and they will be sent to connected peers using Gossipsub
[2023-09-25T12:29:52Z INFO  libp2p_mdns::behaviour::iface] creating instance on iface 192.168.29.99
[2023-09-25T12:29:52Z DEBUG libp2p_quic::transport] New listen address: /ip4/127.0.0.1/udp/60717/quic-v1
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Listener ListenerId(1); New address: "/ip4/127.0.0.1/udp/60717/quic-v1"
Local node is listening on /ip4/127.0.0.1/udp/60717/quic-v1
[2023-09-25T12:29:52Z DEBUG libp2p_quic::transport] New listen address: /ip4/192.168.29.99/udp/60717/quic-v1
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Listener ListenerId(1); New address: "/ip4/192.168.29.99/udp/60717/quic-v1"
Local node is listening on /ip4/192.168.29.99/udp/60717/quic-v1
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] New listen address: /ip4/127.0.0.1/tcp/55432
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Listener ListenerId(2); New address: "/ip4/127.0.0.1/tcp/55432"
Local node is listening on /ip4/127.0.0.1/tcp/55432
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] New listen address: /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Listener ListenerId(2); New address: "/ip4/192.168.29.99/tcp/55432"
Local node is listening on /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:52Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1 /ip4/192.168.29.99/udp/59006/quic-v1
[2023-09-25T12:29:52Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1 /ip4/192.168.29.99/tcp/55431
mDNS discovered a new peer: 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1")
mDNS discovered a new peer: 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1")
[2023-09-25T12:29:52Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55431/p2p/12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1 using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] dialing 192.168.29.99:55431
[2023-09-25T12:29:52Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55431/p2p/12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1 using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] dialing 192.168.29.99:55431
[2023-09-25T12:29:52Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:52Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55433 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:52Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55434 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:52Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:52Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:52Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:52Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:52Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:52Z DEBUG multistream_select::negotiated] Negotiated: Received confirmation for protocol: /noise
[2023-09-25T12:29:52Z DEBUG multistream_select::negotiated] Negotiated: Received confirmation for protocol: /noise
[2023-09-25T12:29:52Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
[2023-09-25T12:29:52Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:52Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Left(Connection(ConnectionError(ConnectionClosed(ConnectionClose { error_code: APPLICATION_ERROR, frame_type: None, reason: b"" })))) }))
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Left(Connection(ConnectionError(ConnectionClosed(ConnectionClose { error_code: APPLICATION_ERROR, frame_type: None, reason: b"" })))) }))
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:52Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:52Z DEBUG yamux::connection] new connection: f3ad5d7d (Client)
[2023-09-25T12:29:52Z DEBUG yamux::connection] new connection: a0cb35fd (Client)
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1") Dialer { address: "/ip4/192.168.29.99/tcp/55431/p2p/12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1", role_override: Dialer }; Total (peer): 1.
[2023-09-25T12:29:52Z DEBUG libp2p_gossipsub::behaviour] New peer connected: 12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:52Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1") Dialer { address: "/ip4/192.168.29.99/tcp/55431/p2p/12D3KooWJ6VXaMXZjc2BQbmXM9WrBBGfjtuM1m1oEaDZMkZAB4A1", role_override: Dialer }; Total (peer): 2.
[2023-09-25T12:29:53Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV /ip4/192.168.29.99/udp/65388/quic-v1
[2023-09-25T12:29:53Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV /ip4/192.168.29.99/tcp/55437
mDNS discovered a new peer: 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV
[2023-09-25T12:29:53Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV
[2023-09-25T12:29:53Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV")
mDNS discovered a new peer: 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV
[2023-09-25T12:29:53Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV
[2023-09-25T12:29:53Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV")
[2023-09-25T12:29:53Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55437/p2p/12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:53Z DEBUG libp2p_tcp] dialing 192.168.29.99:55437
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:53Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55437/p2p/12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:53Z DEBUG libp2p_tcp] dialing 192.168.29.99:55437
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:53Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:53Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55440 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:53Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55443 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:53Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:53Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:53Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:53Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
[2023-09-25T12:29:53Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:53Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] Not resuming
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] Not resuming
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [Protocols([ProtocolName(6c6962703270)]), ServerNameAck, TransportParameters([1, 4, 128, 0, 117, 48, 3, 2, 69, 192, 4, 4, 128, 228, 225, 192, 5, 4, 128, 152, 150, 128, 6, 4, 128, 152, 150, 128, 7, 4, 128, 152, 150, 128, 8, 2, 65, 0, 14, 1, 5, 64, 182, 0, 2, 16, 182, 16, 226, 243, 84, 62, 40, 146, 235, 191, 245, 21, 131, 230, 141, 68, 12, 0, 0, 20, 168, 62, 224, 157, 141, 89, 117, 138, 86, 88, 249, 41, 62, 111, 253, 96, 25, 100, 73, 170, 15, 8, 206, 181, 54, 79, 37, 219, 106, 117, 106, 178, 0])]
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] ALPN protocol is Some(b"libp2p")
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] Got CertificateRequest CertificateRequestPayloadTLS13 { context: , extensions: [SignatureAlgorithms([ECDSA_NISTP384_SHA384, ECDSA_NISTP256_SHA256, ED25519, RSA_PSS_SHA512, RSA_PSS_SHA384, RSA_PSS_SHA256, RSA_PKCS1_SHA512, RSA_PKCS1_SHA384, RSA_PKCS1_SHA256])] }
[2023-09-25T12:29:53Z DEBUG rustls::client::common] Attempting client auth
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [Protocols([ProtocolName(6c6962703270)]), ServerNameAck, TransportParameters([1, 4, 128, 0, 117, 48, 3, 2, 69, 192, 4, 4, 128, 228, 225, 192, 5, 4, 128, 152, 150, 128, 6, 4, 128, 152, 150, 128, 7, 4, 128, 152, 150, 128, 8, 2, 65, 0, 14, 1, 5, 64, 182, 0, 2, 16, 140, 105, 53, 220, 175, 58, 232, 51, 116, 111, 201, 172, 178, 177, 175, 163, 12, 0, 0, 20, 99, 220, 165, 103, 139, 244, 178, 201, 14, 78, 167, 157, 184, 110, 121, 215, 212, 255, 253, 101, 15, 8, 233, 71, 160, 243, 220, 58, 8, 174, 106, 178, 0])]
[2023-09-25T12:29:53Z DEBUG rustls::client::hs] ALPN protocol is Some(b"libp2p")
[2023-09-25T12:29:53Z DEBUG rustls::client::tls13] Got CertificateRequest CertificateRequestPayloadTLS13 { context: , extensions: [SignatureAlgorithms([ECDSA_NISTP384_SHA384, ECDSA_NISTP256_SHA256, ED25519, RSA_PSS_SHA512, RSA_PSS_SHA384, RSA_PSS_SHA256, RSA_PKCS1_SHA512, RSA_PKCS1_SHA384, RSA_PKCS1_SHA256])] }
[2023-09-25T12:29:53Z DEBUG rustls::client::common] Attempting client auth
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Left(Connection(ConnectionError(ConnectionClosed(ConnectionClose { error_code: APPLICATION_ERROR, frame_type: None, reason: b"" })))) }))
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Left(Connection(ConnectionError(ConnectionClosed(ConnectionClose { error_code: APPLICATION_ERROR, frame_type: None, reason: b"" })))) }))
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
[2023-09-25T12:29:53Z DEBUG multistream_select::negotiated] Negotiated: Received confirmation for protocol: /noise
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV") Dialer { address: "/ip4/192.168.29.99/udp/65388/quic-v1/p2p/12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV", role_override: Dialer }; Total (peer): 1.
[2023-09-25T12:29:53Z DEBUG libp2p_gossipsub::behaviour] New peer connected: 12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV
[2023-09-25T12:29:53Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV") Dialer { address: "/ip4/192.168.29.99/udp/65388/quic-v1/p2p/12D3KooWFs64RqpSFTwrnzq9uzGp8bhjp1VjhtxNzs6kSjKKg2qV", role_override: Dialer }; Total (peer): 2.
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Starting heartbeat
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] HEARTBEAT: Mesh low. Topic: test-net Contains: 0 needs: 5
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] RANDOM PEERS: Got 0 peers
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Updating mesh, new mesh: {}
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Completed Heartbeat
[2023-09-25T12:29:57Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM /ip4/192.168.29.99/tcp/55446
[2023-09-25T12:29:57Z INFO  libp2p_mdns::behaviour] discovered: 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM /ip4/192.168.29.99/udp/63982/quic-v1
mDNS discovered a new peer: 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM")
mDNS discovered a new peer: 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Adding explicit peer 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] Connecting to explicit peer PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM")
[2023-09-25T12:29:57Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55446/p2p/12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:57Z DEBUG libp2p_tcp] dialing 192.168.29.99:55446
[2023-09-25T12:29:57Z DEBUG libp2p_core::transport::choice] Failed to dial /ip4/192.168.29.99/tcp/55446/p2p/12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM using libp2p_quic::transport::GenTransport<libp2p_quic::provider::async_std::Provider>
[2023-09-25T12:29:57Z DEBUG libp2p_tcp] dialing 192.168.29.99:55446
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] No cached session for DnsName("l")
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] Not resuming any session
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::negotiated] Negotiated: Received confirmation for protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:57Z DEBUG multistream_select::dialer_select] Dialer: Expecting proposed protocol: /yamux/1.0.0
[2023-09-25T12:29:57Z DEBUG yamux::connection] new connection: e4bfab06 (Client)
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] Not resuming
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] Not resuming
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [Protocols([ProtocolName(6c6962703270)]), ServerNameAck, TransportParameters([1, 4, 128, 0, 117, 48, 3, 2, 69, 192, 4, 4, 128, 228, 225, 192, 5, 4, 128, 152, 150, 128, 6, 4, 128, 152, 150, 128, 7, 4, 128, 152, 150, 128, 8, 2, 65, 0, 14, 1, 5, 64, 182, 0, 2, 16, 49, 100, 156, 74, 214, 97, 215, 199, 23, 209, 179, 249, 137, 191, 226, 17, 12, 0, 0, 20, 183, 193, 24, 187, 165, 10, 177, 171, 23, 255, 222, 7, 49, 138, 177, 68, 44, 152, 179, 38, 15, 8, 231, 186, 231, 210, 239, 161, 77, 81, 106, 178, 0])]
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] ALPN protocol is Some(b"libp2p")
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] Got CertificateRequest CertificateRequestPayloadTLS13 { context: , extensions: [SignatureAlgorithms([ECDSA_NISTP384_SHA384, ECDSA_NISTP256_SHA256, ED25519, RSA_PSS_SHA512, RSA_PSS_SHA384, RSA_PSS_SHA256, RSA_PKCS1_SHA512, RSA_PKCS1_SHA384, RSA_PKCS1_SHA256])] }
[2023-09-25T12:29:57Z DEBUG rustls::client::common] Attempting client auth
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [Protocols([ProtocolName(6c6962703270)]), ServerNameAck, TransportParameters([1, 4, 128, 0, 117, 48, 3, 2, 69, 192, 4, 4, 128, 228, 225, 192, 5, 4, 128, 152, 150, 128, 6, 4, 128, 152, 150, 128, 7, 4, 128, 152, 150, 128, 8, 2, 65, 0, 14, 1, 5, 64, 182, 0, 2, 16, 53, 118, 126, 69, 231, 116, 49, 100, 32, 28, 53, 237, 4, 155, 235, 246, 12, 0, 0, 20, 1, 78, 112, 177, 111, 208, 108, 219, 222, 23, 163, 46, 184, 4, 97, 150, 227, 40, 204, 112, 15, 8, 109, 38, 80, 91, 56, 20, 253, 225, 106, 178, 0])]
[2023-09-25T12:29:57Z DEBUG rustls::client::hs] ALPN protocol is Some(b"libp2p")
[2023-09-25T12:29:57Z DEBUG rustls::client::tls13] Got CertificateRequest CertificateRequestPayloadTLS13 { context: , extensions: [SignatureAlgorithms([ECDSA_NISTP384_SHA384, ECDSA_NISTP256_SHA256, ED25519, RSA_PSS_SHA512, RSA_PSS_SHA384, RSA_PSS_SHA256, RSA_PKCS1_SHA512, RSA_PKCS1_SHA384, RSA_PKCS1_SHA256])] }
[2023-09-25T12:29:57Z DEBUG rustls::client::common] Attempting client auth
[2023-09-25T12:29:57Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55453 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:57Z DEBUG libp2p_tcp] Incoming connection from /ip4/192.168.29.99/tcp/55454 at /ip4/192.168.29.99/tcp/55432
[2023-09-25T12:29:57Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:57Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:57Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
[2023-09-25T12:29:57Z DEBUG multistream_select::negotiated] Negotiated: Received confirmation for protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::listener_select] Listener: confirming protocol: /noise
[2023-09-25T12:29:57Z DEBUG multistream_select::listener_select] Listener: sent confirmed protocol: /noise
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM") Dialer { address: "/ip4/192.168.29.99/tcp/55446/p2p/12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM", role_override: Dialer }; Total (peer): 1.
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:57Z DEBUG libp2p_gossipsub::behaviour] New peer connected: 12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM
[2023-09-25T12:29:57Z DEBUG rustls::server::hs] decided upon suite TLS13_CHACHA20_POLY1305_SHA256
[2023-09-25T12:29:57Z DEBUG rustls::server::hs] Chosen ALPN protocol [108, 105, 98, 112, 50, 112]
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM") Dialer { address: "/ip4/192.168.29.99/udp/63982/quic-v1/p2p/12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM", role_override: Dialer }; Total (peer): 2.
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Incoming connection failed: Transport(Other(Custom { kind: Other, error: Right(Custom { kind: Other, error: Other(Right(Select(Failed))) }) }))
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM") Listener { local_addr: "/ip4/0.0.0.0/udp/60717/quic-v1", send_back_addr: "/ip4/192.168.29.99/udp/63982/quic-v1" }; Total (peer): 3.
thread 'async-std/runtime' panicked at 'overflow when adding duration to instant', library/std/src/time.rs:408:33
[2023-09-25T12:29:57Z DEBUG libp2p_swarm] Connection established: PeerId("12D3KooWHNhyEvUcbNYNQcbZ8M157NWrJVFx1aPi936zcy4PE2KM") Listener { local_addr: "/ip4/0.0.0.0/udp/60717/quic-v1", send_back_addr: "/ip4/192.168.29.99/udp/63982/quic-v1" }; Total (peer): 4.

@dariusc93
Copy link
Member

I've observed this same panic when using KeepAlive::Until with a max duration (prior to the SwarmBuilder::idle_connection_timeout being merged). Since then, from scanning over the code, it looks to be due to

(_, KeepAlive::No) => {
let deadline = Instant::now() + *idle_timeout;
*shutdown = Shutdown::Later(Delay::new(*idle_timeout), deadline);
}

@thomaseizinger
Copy link
Contributor

Ah good catch @dariusc93 !

We shouldn't use + here but checked_add and fall back to a very large Instant.

@thomaseizinger
Copy link
Contributor

@pawanl1x I updated the PR description to only be about the 2nd issue as the first one is known and will be fixed in the next update from trust-dns-proto.

@arpankapoor
Copy link
Contributor

To add to what @dariusc93 pointed out, I have also observed a panic inside Delay::new where a similar unchecked add is used.

Shutdown::Later(Delay::new(effective_keep_alive), earliest_shutdown)

@thomaseizinger
Copy link
Contributor

I've opened a PR for this: #4559

@mergify mergify bot closed this as completed in #4559 Sep 27, 2023
mergify bot pushed a commit that referenced this issue Sep 27, 2023
When adding a very large `Duration` to an `Instant`, an overflow can occur. To fix this, we check this before instantiating `Delay` and half the given duration until it no longer overflows.

Fixes: #4555.

Pull-Request: #4559.
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

Successfully merging a pull request may close this issue.

4 participants