ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.14k stars 19.95k forks source link

[lightserv] panic: runtime error: invalid memory address or nil pointer dereference #15079

Closed kozyilmaz closed 5 years ago

kozyilmaz commented 7 years ago

System information

Observable with both:

v1.6.7-stable-ab5646c5/linux-amd64/go1.9
v1.7.0-unstable-d70536b5/linux-amd64/go1.9

Expected behaviour

Normal operation in a private Ethereum network

Actual behaviour

If --lightserv x is enabled (among other options like --nodiscover) client crashes

Steps to reproduce the behaviour

Able to reproduce it with the command line below, if --lightserv 50 is removed geth works as expected

$ geth --rpc --datadir "~/dir" --nodiscover --networkid 666 --lightserv 50 --verbosity 9 console

Backtrace

$ geth --rpc --datadir "~/dir" --nodiscover --networkid 666 --lightserv 50 --verbosity 9 console
DEBUG[09-02|23:10:41] Reloaded keystore contents               accounts=1
DEBUG[09-02|23:10:41] Reloaded keystore contents               accounts=1
INFO [09-02|23:10:41] Starting peer-to-peer node               instance=Geth/v1.7.0-unstable-d70536b5/linux-amd64/go1.9
INFO [09-02|23:10:41] Allocated cache and file handles         database=/root/bether/geth/chaindata cache=128 handles=1024
TRACE[09-02|23:10:41] Started watching keystore folder         path=/root/bether/keystore
DEBUG[09-02|23:10:41] Reloaded keystore contents               accounts=1
INFO [09-02|23:10:41] Initialised chain configuration          config="{ChainID: 42 Homestead: 0 DAO: <nil> DAOSupport: false EIP150: <nil> EIP155: 0 EIP158: 0 Metropolis: <nil> Engine: unknown}"
INFO [09-02|23:10:41] Disk storage enabled for ethash caches   dir=/root/bether/geth/ethash count=3
INFO [09-02|23:10:41] Disk storage enabled for ethash DAGs     dir=/root/.ethash            count=2
INFO [09-02|23:10:41] Initialising Ethereum protocol           versions="[63 62]" network=666
INFO [09-02|23:10:41] Loaded most recent local header          number=9306 hash=b4a788…1258ec td=3020982939
INFO [09-02|23:10:41] Loaded most recent local full block      number=9306 hash=b4a788…1258ec td=3020982939
INFO [09-02|23:10:41] Loaded most recent local fast block      number=9306 hash=b4a788…1258ec td=3020982939
INFO [09-02|23:10:41] Loaded local transaction journal         transactions=0 dropped=0
INFO [09-02|23:10:41] Regenerated local transaction journal    transactions=0 accounts=0
WARN [09-02|23:10:41] Blockchain not empty, fast sync disabled 
DEBUG[09-02|23:10:41] Recalculated downloader QoS values       rtt=20s confidence=1.000 ttl=1m0s
INFO [09-02|23:10:41] Starting P2P networking 
DEBUG[09-02|23:10:41] InProc registered *node.PrivateAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] InProc registered *node.PublicAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] InProc registered *debug.HandlerT under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *node.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *node.PublicWeb3API under 'web3' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicBlockChainAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicTransactionPoolAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicTxPoolAPI under 'txpool' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PrivateDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicAccountAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PrivateAccountAPI under 'personal' 
DEBUG[09-02|23:10:41] InProc registered *eth.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *eth.PublicMinerAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *downloader.PublicDownloaderAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *eth.PrivateMinerAPI under 'miner' 
DEBUG[09-02|23:10:41] InProc registered *filters.PublicFilterAPI under 'eth' 
DEBUG[09-02|23:10:41] InProc registered *eth.PrivateAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] InProc registered *eth.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *eth.PrivateDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] InProc registered *ethapi.PublicNetAPI under 'net' 
DEBUG[09-02|23:10:41] IPC registered *node.PrivateAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] IPC registered *node.PublicAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] IPC registered *debug.HandlerT under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *node.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *node.PublicWeb3API under 'web3' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicBlockChainAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicTransactionPoolAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicTxPoolAPI under 'txpool' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PrivateDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicAccountAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PrivateAccountAPI under 'personal' 
DEBUG[09-02|23:10:41] IPC registered *eth.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *eth.PublicMinerAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *downloader.PublicDownloaderAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *eth.PrivateMinerAPI under 'miner' 
DEBUG[09-02|23:10:41] IPC registered *filters.PublicFilterAPI under 'eth' 
DEBUG[09-02|23:10:41] IPC registered *eth.PrivateAdminAPI under 'admin' 
DEBUG[09-02|23:10:41] IPC registered *eth.PublicDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *eth.PrivateDebugAPI under 'debug' 
DEBUG[09-02|23:10:41] IPC registered *ethapi.PublicNetAPI under 'net' 
DEBUG[09-02|23:10:41] HTTP registered *node.PublicWeb3API under 'web3' 
DEBUG[09-02|23:10:41] HTTP registered *ethapi.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *ethapi.PublicBlockChainAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *ethapi.PublicTransactionPoolAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *ethapi.PublicAccountAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *eth.PublicEthereumAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *eth.PublicMinerAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *downloader.PublicDownloaderAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *filters.PublicFilterAPI under 'eth' 
DEBUG[09-02|23:10:41] HTTP registered *ethapi.PublicNetAPI under 'net' 
INFO [09-02|23:10:41] HTTP endpoint opened: http://127.0.0.1:8545 
INFO [09-02|23:10:41] RLPx listener up                         self="enode://bec8c5faf7826d40c19ca115689a1c33580ac9b9c032f971dbe4d1571b4563f86a12df68165beee2a04e3a811bd134ede95d1540c3426022cc898e1893456e51@[::]:30303?discport=0"
INFO [09-02|23:10:41] Starting topic registration              topic=LES@89106488091a5cfe
INFO [09-02|23:10:41] Terminated topic registration            topic=LES@89106488091a5cfe
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x68 pc=0x999d1a]

goroutine 47 [running]:
github.com/ethereum/go-ethereum/p2p/discv5.(*Network).RegisterTopic(0x0, 0xc420187700, 0x14, 0xc42034e360)
    /root/devel/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/p2p/discv5/net.go:295 +0x3a
github.com/ethereum/go-ethereum/les.(*LesServer).Start.func1(0xc420358340, 0xc42049a8c0)
    /root/devel/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/les/server.go:85 +0x197
created by github.com/ethereum/go-ethereum/les.(*LesServer).Start
    /root/devel/go-ethereum/build/_workspace/src/github.com/ethereum/go-ethereum/les/server.go:80 +0x5a
OniReimu commented 6 years ago

The same. any solutions? It seems like net.topicRegisterReq in p2p/discv5/net.go line 295 has not been defined. And I learnt that the only call for func newNetwork() is likely in p2p/discv5/udp.go line 245. However, we look at p2p/server.go line 384, only if srv.DiscoveryV5 == true, then discv5.ListenUDPwill be called. Dose it mean this panic always happens if we have setting--nodiscover and not setting --v5disc? And thereby we are not able to set it to manual peer addition with light clients?

kozyilmaz commented 6 years ago

Thanks for your analysis @OniReimu @zsfelfoldi Any plans for a resolution in near future, it is creating problems for private networks.

OniReimu commented 6 years ago

Found a workaround. In les/server.go func (s *LesServer) Start(srvr *p2p.Server){): Comment out:

    // go func() {
    //  logger := log.New("topic", s.lesTopic)
    //  logger.Info("Starting topic registration")
    //  defer logger.Info("Terminated topic registration")

    //  srvr.DiscV5.RegisterTopic(s.lesTopic, s.quitSync)
    // }()

And all good. I am not that sure the purpose they have this new goroutine here as it does not exist in the older version. I will figure it out later see if there will exist some unexpected behaviours if this code being commented out.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

adamschmideg commented 5 years ago

outdated