ethereum / go-ethereum

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

goroutine leaks in TestClientCancelIPC #24212

Open charlesxsh opened 2 years ago

charlesxsh commented 2 years ago

System information

Geth version: geth version OS & Version: Windows/Linux/OSX Commit hash : (if develop)

Expected behaviour

no goroutine leaks

Actual behaviour

all rpc call goroutine leaks

Steps to reproduce the behaviour

func testClientCancel(transport string, t *testing.T) {
   server := newTestServer() // line 1
   defer server.Stop()

   // in a lambda, that will be called in new goroutine and a loop
   err := client.CallContext(ctx, nil, "test_block") // line 2
func (s *testService) Block(ctx context.Context) error {
   <-ctx.Done()
   return errors.New("context canceled in testservice_block")
}

Backtrace

goroutine 102 [chan receive]:
github.com/ethereum/go-ethereum/rpc.(*testService).Block(0xc25ae8, 0x936c98, 0xc000645200, 0x0, 0x0)
   /repos/go-ethereum/rpc/testservice_test.go:95 +0xc5
reflect.Value.call(0xc00002d2c0, 0xc00000e150, 0x13, 0x8a66e3, 0x4, 0xc000690b40, 0x2, 0x2, 0xc000143bf0, 0x45bd4c, ...)
   /usr/local/go/src/reflect/value.go:476 +0x8e7
reflect.Value.Call(0xc00002d2c0, 0xc00000e150, 0x13, 0xc000690b40, 0x2, 0x2, 0x92fa80, 0xc00006a120, 0xc000059800)
   /usr/local/go/src/reflect/value.go:337 +0xb9
github.com/ethereum/go-ethereum/rpc.(*callback).call(0xc00002d320, 0x936c98, 0xc000645200, 0xc00020c3e0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
   /repos/go-ethereum/rpc/service.go:220 +0x2e5
github.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0xc0000c3560, 0x936c98, 0xc000645200, 0xc0000cc850, 0xc00002d320, 0x0, 0x0, 0x0, 0x0)
   /repos/go-ethereum/rpc/handler.go:417 +0xb1
github.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0xc0000c3560, 0xc000690a80, 0xc0000cc850, 0x1)
   /repos/go-ethereum/rpc/handler.go:363 +0x252
github.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0xc0000c3560, 0xc000690a80, 0xc0000cc850, 0x932a01)
   /repos/go-ethereum/rpc/handler.go:323 +0xfb
github.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0xc000690a80)
   /repos/go-ethereum/rpc/handler.go:144 +0x46
github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1(0xc0000c3560, 0xc0004de078)
   /repos/go-ethereum/rpc/handler.go:246 +0xd3
created by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc
   /repos/go-ethereum/rpc/handler.go:242 +0xdb

Do we have any way to fix this issue? When submitting logs: please submit them as text and not screenshots.

holiman commented 2 years ago

This is not trivial to fix, and not highly prio since it's only the tests framework leaking goroutines, not the actual production runtime.