Skip to content

p2p/discover: UDP listener port not released when macOS firewall is enabled #18443

Open
@ryanberckmans

Description

@ryanberckmans

System information

Geth
Version: 1.8.20-stable
Git Commit: 24d727b6d6e2c0cde222fa12155c4a6db5caaf2e
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.11.2
Operating System: darwin (OSX 10.13.6)
GOPATH=/Users/me/go
GOROOT=/Users/travis/.gimme/versions/go1.11.2.darwin.amd64

Expected behaviour

Discovery UDP listener should close socket on shutdown/interrupt in all cases.

Actual behaviour

In certain code paths, the discovery UDP listener is not closed on shutdown/interrupt, preventing geth from restarting until the port is manually released or system restarted.

I hit one of these code paths but don't have a specific repro.

Invocation that produced dangling UDP listener (light node):

geth --syncmode=light --cache=512 --rpc --ws --wsorigins=127.0.0.1,http://127.0.0.1:8080,https://127.0.0.1:8443 --datadir=redact

Listener initialization which became dangling:

  [14:57:00.418] [info] GETH NODE: INFO [01-14|14:57:00.418] UDP listener up                          net=enode:/redact@[::]:30303

Interrupt which failed to close UDP listener:

  [14:57:30.059] [info] GETH NODE: INFO [01-14|14:57:30.004] Got interrupt, shutting down...
  INFO [01-14|14:57:30.004] WebSocket endpoint closed                url=ws://127.0.0.1:8546
  INFO [01-14|14:57:30.005] HTTP endpoint closed                     url=http://127.0.0.1:8545
  INFO [01-14|14:57:30.005] IPC endpoint closed                      url="/Users/me/Library/Application Support/augur/geth/geth.ipc"
  INFO [01-14|14:57:30.005] Blockchain manager stopped
  INFO [01-14|14:57:30.005] Stopping light Ethereum protocol
  INFO [01-14|14:57:30.007] Light Ethereum protocol stopped
  INFO [01-14|14:57:30.008] Transaction pool stopped

Fatal when attempting to restart geth:

Fatal: Error starting protocol stack: listen udp [::]:30303: bind: address already in use

Util showing port not released:

$ netstat -anv | grep "30303|pid"
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)     rhiwat shiwat    pid   epid
udp46  58303      0  *.30303                *.*                                196724   9216  45852      0

Confirm pid 45852 doesn't exist (ie. port is unreleased after process killed; not unkilled/zombie process)

$ ps -e | grep 45852
// empty

Metadata

Metadata

Assignees

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