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

Avoid crash when tunnel cannot be opened #2860

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

jandubois
Copy link
Member

@jandubois jandubois commented Nov 7, 2024

When client.Tunnel() returns an error, then the returned stream is invalid and must not be used.

Fixes this crash during shutdown:

{"level":"error","msg":"could not open tcp tunnel for id: tcp-[::1]:80-[::1]:50544 error:rpc error: code = Canceled desc = context canceled","time":"2024-11-06T20:03:38-08:00"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x10386a022]

goroutine 1056 [running]:
github.com/lima-vm/lima/pkg/portfwd.GrpcClientRW.Read({{0xc001dc31e8, 0x18}, {0xc000988530, 0xa}, {0x0, 0x0}}, {0xc0022da000, 0x8000, 0x0?})
	/Users/jan/suse/lima/pkg/portfwd/client.go:135 +0x42
io.copyBuffer({0x103dc6000, 0xc001b083e0}, {0x103dc7500, 0xc000adef00}, {0x0, 0x0, 0x0})
	/usr/local/Cellar/go/1.23.2/libexec/src/io/io.go:429 +0x191

When client.Tunnel() returns an error, then the returned
stream is invalid and must not be used.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 4d56dab into lima-vm:master Nov 7, 2024
29 checks passed
@jandubois jandubois deleted the tunnel-error branch January 15, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants