Closed
Description
SUMMARY
On OpenBSD -current as of 2024-09-04 I have following backtrace from a core dump:
Core was generated by `python3.11'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000008cf814426a8 in __pyx_type_11pylibsshext_7channel_Channel ()
from /usr/local/lib/python3.11/site-packages/pylibsshext/channel.cpython-311.so
(gdb) bt
#0 0x000008cf814426a8 in __pyx_type_11pylibsshext_7channel_Channel ()
from /usr/local/lib/python3.11/site-packages/pylibsshext/channel.cpython-311.so
#1 0x000008cf979ac6c4 in ssh_packet_socket_controlflow_callback () from /usr/local/lib/libssh.so.4.2
#2 0x000008cf979b842b in ssh_socket_pollcallback () from /usr/local/lib/libssh.so.4.2
#3 0x000008cf979b4365 in ssh_poll_ctx_dopoll () from /usr/local/lib/libssh.so.4.2
#4 0x000008cf979b5bb6 in ssh_handle_packets () from /usr/local/lib/libssh.so.4.2
#5 0x000008cf979b595b in ssh_handle_packets_termination () from /usr/local/lib/libssh.so.4.2
#6 0x000008cf97993195 in channel_open () from /usr/local/lib/libssh.so.4.2
#7 0x000008cf8143a3ac in __pyx_pf_11pylibsshext_7channel_7Channel_24exec_command (__pyx_v_self=0x8cf82114ac0,
__pyx_v_command=<error reading variable: Cannot access memory at address 0x0>) at pylibsshext/channel.c:7221
#8 __pyx_pw_11pylibsshext_7channel_7Channel_25exec_command (
__pyx_v_self=<pylibsshext.channel.Channel at remote 0x8cf82114ac0>, __pyx_args=<optimized out>,
__pyx_nargs=<optimized out>, __pyx_kwds=<optimized out>) at pylibsshext/channel.c:7138
#9 0x000008cedc9a264d in PyObject_Vectorcall () from /usr/local/lib/libpython3.11.so.0.0
#10 0x000008cedcabb1cd in _PyEval_EvalFrameDefault () from /usr/local/lib/libpython3.11.so.0.0
#11 0x000008cedcaaab1e in PyEval_EvalCode () from /usr/local/lib/libpython3.11.so.0.0
#12 0x000008cedcb1b6e9 in run_mod () from /usr/local/lib/libpython3.11.so.0.0
#13 0x000008cedcb1b1d5 in _PyRun_SimpleFileObject () from /usr/local/lib/libpython3.11.so.0.0
#14 0x000008cedcb1a3b3 in _PyRun_AnyFileObject () from /usr/local/lib/libpython3.11.so.0.0
#15 0x000008cedcb44172 in Py_RunMain () from /usr/local/lib/libpython3.11.so.0.0
#16 0x000008cedcb45095 in pymain_main () from /usr/local/lib/libpython3.11.so.0.0
#17 0x000008cedcb454bc in Py_BytesMain () from /usr/local/lib/libpython3.11.so.0.0
#18 0x000008ccc9b7c94b in _start ()
ISSUE TYPE
- Bug Report
PYLISSH and LIBSSH VERSION
$ python3 version.py
__full_version__='<pylibsshext v1.2.2 with libssh v0.10.6>'
__libssh_version__='0.10.6'
__version__='1.2.2'
__version_info__=(1, 2, 2)
OS / ENVIRONMENT
OpenBSD 7.6-beta (GENERIC.MP) #310: Wed Sep 4 11:59:45 MDT 2024
deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
# pkg_info -qI python
python-3.11.10p0
# pkg_info -qI libssh
libssh-0.10.6
# pkg_info -qI py3-ansible-libssh
py3-ansible-libssh-1.2.2
STEPS TO REPRODUCE
$ cat test1.py
#!/usr/bin/env python3
from pylibsshext.errors import LibsshSessionException
from pylibsshext.session import Session
import logging
HOST = "examplemachine1"
USER = "root"
TIMEOUT = 30
PORT = 22
ssh = Session()
# ssh.set_log_level(logging.DEBUG)
try:
ssh.connect(
host=HOST,
user=USER,
timeout=TIMEOUT,
port=PORT,
# proxycommand="ssh -q -W %h:%p ks2",
)
except LibsshSessionException as ex:
print(f"Failed to connect to {HOST}:{PORT} over SSH: {ex!s}")
print(f"ssh.is_connected={ssh.is_connected}")
def run_cmd(ssh_channel, cmd):
print(f"Running {cmd}...", flush=True)
print(f"Executing exec_command()...", flush=True)
cmd_resp = ssh_channel.exec_command(cmd)
print(f"Executing exec_command()... done", flush=True)
print(f"stdout type: {type(cmd_resp.stdout)}")
print(f"stdout:\n{cmd_resp.stdout.decode()}\n")
print(f"stderr type: {type(cmd_resp.stderr)}")
print(f"stderr:\n{cmd_resp.stderr.decode()}\n")
print(f"return code: {cmd_resp.returncode}")
ssh_channel = ssh.new_channel()
run_cmd(ssh_channel, "uptime")
run_cmd(ssh_channel, "ls")
run_cmd(ssh_channel, "hostname")
print(f"Executing ssh_channel.close()...", flush=True)
ssh_channel.close()
print("Closing connection...", flush=True)
ssh.close()
EXPECTED RESULTS
Execution of below script should work all the time, but it code dumps intermittently.
python3 test1.py
ACTUAL RESULTS
Core dumps every now and then. Always on second command. First command always works.
$ python3 test1.py
ssh.is_connected=1
Running uptime...
Executing exec_command()...
Executing exec_command()... done
stdout type: <class 'bytes'>
stdout:
7:17PM up 1 day, 15:59, 0 users, load averages: 0.01, 0.01, 0.00
stderr type: <class 'bytes'>
stderr:
return code: 0
Running ls...
Executing exec_command()...
Segmentation fault (core dumped)
Metadata
Metadata
Assignees
Labels
No labels