pytogo / portforward

Kubernetes Port-Forward Go-Edition For Python
https://portforward.readthedocs.io
MIT License
17 stars 6 forks source link

Bug: Segmentation Fault on portforward close. #19

Closed atti92 closed 1 year ago

atti92 commented 1 year ago

Description

Closing the portfoward gives Segmentation Fault. It happens 100% of the time. 0.4.2 works without any problem.

What I Did

>>> import portforward
>>> fw = portforward.forward("namespace", "podname", 5080, 53823)
>>> fw.__enter__()
DEBUG: Forwarding from 127.0.0.1:5080 -> 53823

DEBUG: Error listener timeout - nothing happend
>>> fw.__exit__(None, None, None)
False
>>> panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7f80b9f1c81f]

goroutine 25 [running]:
github.com/pytogo/pytogo/portforward.startForward.func2(0xc00001ed10, 0xc0004b22d0, 0xc0002b7260, 0xc000411ec8)
        /tmp/tmpg5vghknl/pkg/mod/github.com/pytogo/pytogo/portforward@v0.0.0-20230228203735-ca55e0707768/portforward.go:323 +0x5f
created by github.com/pytogo/pytogo/portforward.startForward
        /tmp/tmpg5vghknl/pkg/mod/github.com/pytogo/pytogo/portforward@v0.0.0-20230228203735-ca55e0707768/portforward.go:319 +0x2bf
Aborted (core dumped)

On 0.4.2 this looks like this:

>>> import portforward
>>> fw = portforward.forward("namespace", "podname", 5080, 53823)
>>> fw.__enter__()
DEBUG: Forwarding from 127.0.0.1:5080 -> 53823

>>> fw.__exit__(None, None, None)
False

Note:

corka149 commented 1 year ago

Hi,

thx for your issue. The bug is a bit embarrassing. I created a fix and will publish 0.4.5 today.

I will keep the issue open regarding the feature request:

It would be nice to have open-close in addition to the context manager.

nidabdella commented 1 year ago

Hello @corka149, Thank you for this module. Shouldn't __exit__() stop the portforwarding ?

corka149 commented 1 year ago

Hey @nidabdella , yes should be the case. If there is a bug that you know, O would be very happy about a new issue with steps to reproduce it.

corka149 commented 1 year ago

This will be part of the next minor release:

It would be nice to have open-close in addition to the context manager.

corka149 commented 1 year ago

The feature will be released with version 0.5.0 today. The class PortForwarder also you to use portforwarding without context manager.

Thx for the issue!