Skip to content

A potential goroutine leak in clientconn_parsed_target_test.go #8695

@user12031

Description

@user12031

Blocking position:

addrCh <- address

How to reproduce:
1.Add time.Sleep(time.Second * 10) before cc.mu.Lock()

cc.mu.Lock()

, which make the cc.mu.Lock() get executed later.

time.Sleep(time.Second * 10)
cc.mu.Lock()

2.Using goleak to detect the bug in the test function

func (s) TestParsedTarget_WithCustomDialer(t *testing.T) {

func TestParsedTarget_WithCustomDialer(t *testing.T) {
	defer goleak.VerifyNone(t)

Output:

 clientconn_parsed_target_test.go:327: found unexpected goroutines:
        [Goroutine 137 in state chan send, with google.golang.org/grpc.TestParsedTarget_WithCustomDialer.func1.1 on top of the stack:
        google.golang.org/grpc.TestParsedTarget_WithCustomDialer.func1.1({0xc0001e0210?, 0xa9cda0?}, {0xbd3b99, 0xa})
        	/home/song2048/桌面/goProject/src/grpc-go-master/clientconn_parsed_target_test.go:303 +0x26
        google.golang.org/grpc/internal/transport.dial({0xcc2068, 0xc0001e05a0}, 0xc0001d3f10, {{0xbd3b99, 0xa}, {0xbd3b99, 0xa}, 0x0, 0x0, {0x0, ...}}, ...)
        	/home/song2048/桌面/goProject/src/grpc-go-master/internal/transport/http2_client.go:177 +0x214
        google.golang.org/grpc/internal/transport.NewHTTP2Client({_, _}, {_, _}, {{0xbd3b99, 0xa}, {0xbd3b99, 0xa}, 0x0, 0x0, ...}, ...)
        	/home/song2048/桌面/goProject/src/grpc-go-master/internal/transport/http2_client.go:222 +0x168
        google.golang.org/grpc.(*addrConn).createTransport(_, {_, _}, {{0xbd3b99, 0xa}, {0xbd3b99, 0xa}, 0x0, 0x0, {0x0, ...}}, ...)
        	/home/song2048/桌面/goProject/src/grpc-go-master/clientconn.go:1403 +0x285
        google.golang.org/grpc.(*addrConn).tryAllAddrs(0xc0001c1808, {0xcc20a0, 0xc000035c70}, {0xc0001d4a40?, 0xc000010ca8?, 0xc0000bddc0?}, {0xc000054b80?, 0x0?, 0x11ad6c0?})
        	/home/song2048/桌面/goProject/src/grpc-go-master/clientconn.go:1350 +0x468
        google.golang.org/grpc.(*addrConn).resetTransportAndUnlock(0xc0001c1808)
        	/home/song2048/桌面/goProject/src/grpc-go-master/clientconn.go:1282 +0x1c5
        google.golang.org/grpc.(*addrConn).connect(0xc0001c1808)
        	/home/song2048/桌面/goProject/src/grpc-go-master/clientconn.go:945 +0x145
        created by google.golang.org/grpc.(*acBalancerWrapper).Connect in goroutine 135
        	/home/song2048/桌面/goProject/src/grpc-go-master/balancer_wrapper.go:354 +0x56

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions