Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:A potential goroutine leak in libnetwork/drivers/overlay/peerdb.go #2680

Closed
xuxiaofan1203 opened this issue Apr 6, 2024 · 3 comments
Closed

Comments

@xuxiaofan1203
Copy link

xuxiaofan1203 commented Apr 6, 2024

Hello @olljanat, the libnetwork is useful, but I found a bug when I used it, I think we can fix it.
In the test file

func TestOverlayType(t *testing.T) {
dt := &driverTester{t: t}
if err := Init(dt, nil); err != nil {
t.Fatal(err)
}
if dt.d.Type() != testNetworkType {
t.Fatalf("Expected Type() to return %q. Instead got %q", testNetworkType,
dt.d.Type())
}
}

After the Init has executed and the ctx and cancel are created at
ctx, cancel := context.WithCancel(context.Background())
d.peerOpCancel = cancel
go d.peerOpRoutine(ctx, d.peerOpCh)

There is no cancelFunc to awaken the ctx.Done() at
case <-ctx.Done():

So the goroutine will block, and you can use the goleak to reproduce the bug like this

func TestOverlayType(t *testing.T) {
	defer goleak.VerifyNone(t)
	dt := &driverTester{t: t}
	if err := Init(dt, nil); err != nil {
		t.Fatal(err)
	}

	if dt.d.Type() != testNetworkType {
		t.Fatalf("Expected Type() to return %q. Instead got %q", testNetworkType,
			dt.d.Type())
	}
}

1712385445732
And I think we can fix the bug by calling the cleanupDriver() after the init() gets executed.

@xuxiaofan1203 xuxiaofan1203 changed the title A potential goroutinue leak [Bug]:A potential goroutinue leak Apr 28, 2024
@xuxiaofan1203 xuxiaofan1203 changed the title [Bug]:A potential goroutinue leak [Bug]:A potential goroutine leak May 14, 2024
@xuxiaofan1203 xuxiaofan1203 changed the title [Bug]:A potential goroutine leak [Bug]:A potential goroutine leak in libnetwork/drivers/overlay/peerdb.go May 14, 2024
@olljanat
Copy link
Contributor

olljanat commented May 14, 2024

@xuxiaofan1203 please note what is wrote to readme:

Warning libnetwork was moved to https://github.com/moby/moby/tree/master/libnetwork

So double check if same issue still exists latest code int there and report it there if it does.
Also note that I'm not Moby maintainer but they are looking for that there in there.

@xuxiaofan1203
Copy link
Author

@xuxiaofan1203 please note what is wrote to readme:

Warning libnetwork was moved to https://github.com/moby/moby/tree/master/libnetwork

So double check if same issue still exists latest code int there and report it there if it does. Also note that I'm not Moby maintainer but they are looking for that there in there.

Thank you for your reply and help, I will check again there. And I'm sorry to bother you.

@akerouanton
Copy link
Member

As already noted by @olljanat, this repo is now defunct and not actively watched by maintainers. Also, it seems this goroutine leak only exists in an isolated test due to how it's written. So let me close this issue.

@akerouanton akerouanton closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants