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

Test swarm:multiple_addresses_err fails #2874

Closed
kpp opened this issue Sep 6, 2022 · 6 comments · Fixed by #2882
Closed

Test swarm:multiple_addresses_err fails #2874

kpp opened this issue Sep 6, 2022 · 6 comments · Fixed by #2882

Comments

@kpp
Copy link
Contributor

kpp commented Sep 6, 2022

assert_eq!(

$ git log -n1
commit b8c3b282eee5d6387a9cf2f64af0253e764c1172 (HEAD -> master, origin/master, origin/HEAD)
Author: Alexander Shishenko <alex@shishenko.com>
Date:   Mon Sep 5 07:31:13 2022 +0300
rust-libp2p/swarm$ while true; do RUST_BACKTRACE=1 cargo t multiple_addresses_err --all-features || break; done

...

test tests::multiple_addresses_err ... FAILED

failures:

---- tests::multiple_addresses_err stdout ----
thread 'tests::multiple_addresses_err' panicked at 'assertion failed: `(left == right)`
  left: `["/udp/16140/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/ip4/0.0.0.0/tcp/7391/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/58510/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/5146/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/24313/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/29274/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48"]`,
 right: `["/udp/16140/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/ip4/0.0.0.0/tcp/7391/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/58510/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/5146/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/24313/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48", "/udp/29274/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48"]`', swarm/src/lib.rs:2465:25
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:181:5
   4: libp2p_swarm::tests::multiple_addresses_err::{{closure}}
             at ./src/lib.rs:2465:25
   5: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at /home/kpp/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.24/src/future/poll_fn.rs:56:9
   6: futures_executor::local_pool::block_on::{{closure}}
             at /home/kpp/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.24/src/local_pool.rs:317:23
   7: futures_executor::local_pool::run_executor::{{closure}}
             at /home/kpp/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.24/src/local_pool.rs:90:37
   8: std::thread::local::LocalKey<T>::try_with
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/local.rs:445:16
   9: std::thread::local::LocalKey<T>::with
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/local.rs:421:9
  10: futures_executor::local_pool::run_executor
             at /home/kpp/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.24/src/local_pool.rs:86:5
  11: futures_executor::local_pool::block_on
             at /home/kpp/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-executor-0.3.24/src/local_pool.rs:317:5
  12: libp2p_swarm::tests::multiple_addresses_err
             at ./src/lib.rs:2453:9
  13: libp2p_swarm::tests::multiple_addresses_err::{{closure}}
             at ./src/lib.rs:2429:5
  14: core::ops::function::FnOnce::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
  15: core::ops::function::FnOnce::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    tests::multiple_addresses_err
@kpp
Copy link
Contributor Author

kpp commented Sep 6, 2022

Formatting left and right gives:

left: `["/udp/16140/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
  
"/ip4/0.0.0.0/tcp/7391/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
"/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
"/udp/58510/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
"/udp/5146/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
"/udp/24313/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
"/udp/29274/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48"
]`,

right: `["/udp/16140/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 
 "/ip4/0.0.0.0/tcp/7391/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/udp/58510/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/udp/5146/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/udp/24313/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48",
 "/udp/29274/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48"
]`

So there is a duplicate /ip4/0.0.0.0/tcp/12545/p2p/1AdgJ5v3F2GQFjzyqSqgMA6UGs26X7WXA4m2nfrf1b9R48 on the right.

@thomaseizinger
Copy link
Contributor

This is strange.

I see you ran the test in a loop for it to fail. How many times did you have to run it for it to break?

@thomaseizinger
Copy link
Contributor

I just tried it on my computer and it took 11m for it to finally fail.

@thomaseizinger
Copy link
Contributor

Ha, so this is a funny one! We are generating a total of 8 addresses to dial. If - by chance - we are generating the same port twice, we will dial the same address twice but only receive one dial error back. This is what is happening here. We can see that because "left" are the failed addresses (only 7) and right are 8 addresses, including a duplicate one.

The odd thing about the test is that the expected and actual values are IMO flipped. I'd expect (no pun intended) that "expected" is left and "actual" is right.

In any case, to make this rather rare test failure go away, we simply need to use a HashSet instead of a Vec. I am gonna prepare a PR.

@kpp
Copy link
Contributor Author

kpp commented Sep 9, 2022

I just tried it on my computer and it took 11m for it to finally fail.

I would have never caught this one on my own but the CI caught it right after I merged master into my branch =)

@mxinden
Copy link
Member

mxinden commented Sep 11, 2022

Thanks for debugging here!

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.

3 participants