Repository navigation
Conversation
When a UDP session ends, a new packet from the same source creates a replacement connection under the same key. The old session's goroutine then deleted that key unconditionally, removing the replacement it did not own. The replacement kept running outside the map, and if the checker was stopped, the next new connection's synchronous cleanup could find the map empty and panic in common.Must with "no more connections. stopping..." (v2fly#3777). Remove a connection only while it is still the one registered for its key. This also covers the case the inactive flag handled (the checker already removed it), so drop that unsynchronized flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3777.
When a UDP session ends, the next packet from the same source creates a replacement
udpConnunder the sameconnID. The old session's goroutine then calledremoveConn(id), which deleted whatever was stored under that key, i.e. the replacement. The replacement then runs outsideactiveConn. If the checker has stopped (it stops when a tick finds the map empty), the next new connection runsclean()synchronously fromchecker.Start(). A stale delete landing betweengetConnectionand thatclean()leaves the map empty, andcommon.Mustpanics withno more connections. stopping..., the frame in #3777.removeConnnow deletes only while the map still holds that same connection. That also covers what theinactiveflag from #1305 handled (the checker already removed the conn), so the flag, which was written under the worker lock but read without it, is gone. This follows the direction sketched in #3777 but keeps the checker lifecycle unchanged.TestUDPWorkerEndedSessionKeepsReplacementConndrives two sessions from one source throughcallbackand checks that ending the first leaves the second registered. It fails on master and passes with this change. A local stress loop (one source, short checker interval) hit the same panic within milliseconds on master and ran 8M packets over 10 s without it after the change.go test -race -count=3 ./app/proxyman/inbound/is clean on Linux.