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

holepunch: race condition with identifyWait #2163

Closed
sukunrt opened this issue Mar 2, 2023 · 5 comments · Fixed by #2173
Closed

holepunch: race condition with identifyWait #2163

sukunrt opened this issue Mar 2, 2023 · 5 comments · Fixed by #2173

Comments

@sukunrt
Copy link
Member

sukunrt commented Mar 2, 2023

Currently holepunch calls hs.ids.IdentifyWait(conn) inside the netNotifee.Connected call.
But IdentifyWait requires netNotifee.Connected call to identify to be completed.

https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/holepunch/holepuncher.go#L262

Swarm doesn't guarantee any ordering on notifcations. The notifees are obtained from map keys.

@sukunrt sukunrt changed the title holepunch: race condition with idenityWait holepunch: race condition with identifyWait Mar 2, 2023
@marten-seemann
Copy link
Contributor

Is that a race condition? The IdentifyWait is called in a Go routine. Wouldn't it just wait until it has received the swarm notification?

@sukunrt
Copy link
Member Author

sukunrt commented Mar 2, 2023

I think it doesn't. IdentifyWait assumes the Connected call is completed before calling identifyWait.
https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/identify/id.go#L347

The entry is added here
https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/identify/id.go#L889

@sukunrt
Copy link
Member Author

sukunrt commented Mar 2, 2023

the relevant identifyWait line is this.
https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/identify/id.go#L352

@marten-seemann
Copy link
Contributor

Can you explain how things go wrong when this race condition is triggered?

@sukunrt
Copy link
Member Author

sukunrt commented Mar 2, 2023

we will skip this block where we try to direct dial before hole punch
https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/holepunch/holepuncher.go#L110

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.

2 participants