Stack hung in scp when set to non-blocking

Colin Whittaker colin.whittaker at adtran.com
Mon Feb 5 18:22:53 CET 2024


Our App uses libssh2 to do scp in the non-blocking mode.
Works great normally.
Currently running OWRT version 1.11.0-pre1 from PKG_SOURCE_DATE:=2022-04-11.
Ran into a forever loop today.
Looks like scp_recv() ran into an error mid file transfer and tried to free the channel.
Now the recvfrom on the socket always returns -EAGAIN and the app is stuck in the while loop in libssh2_channel_close() forever.
Anyone see anything like this ? Any chance it is fixed in the release ?

Another weird thing is the socket, which was valid at one point, is still in the ESTABLISHED state according to the system, but the IP that it is connected to is long gone. Not even in the ARP table any longer.
Does libssh2 set some socket option to disable keep alive ?

#0  __cp_end () at src/thread/aarch64/syscall_cp.s:30
#1  0x0000007fa1d77ba4 in __syscall_cp_c (nr=207, u=<optimized out>, v=<optimized out>, w=<optimized out>, x=<optimized out>,
    y=<optimized out>, z=<optimized out>) at src/thread/pthread_cancel.c:33
#2  0x0000007fa1d5d880 in __alt_socketcall (f=f at entry=0, e=e at entry=0, d=<optimized out>, c=<optimized out>, b=<optimized out>,
    a=<optimized out>, cp=1, sock=12, sys=207) at ./src/internal/syscall.h:64
#3  recvfrom (fd=<optimized out>, buf=<optimized out>, len=<optimized out>, flags=<optimized out>, addr=addr at entry=0x0, alen=alen at entry=0x0)
    at src/network/recvfrom.c:6
#4  0x0000007fa1d5d858 in recv (fd=<optimized out>, buf=<optimized out>, len=<optimized out>, flags=<optimized out>) at src/network/recv.c:5
#5  0x0000007fa1cb3314 in _libssh2_recv (sock=<optimized out>, buffer=<optimized out>, length=<optimized out>, flags=<optimized out>,
    abstract=<optimized out>) at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/misc.c:140
#6  0x0000007fa1cbfecc in _libssh2_transport_read (session=session at entry=0x7fa16092b0)
    at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/transport.c:369
#7  0x0000007fa1ca8910 in _libssh2_channel_close (channel=channel at entry=0x7fa171c010)
    at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/channel.c:2616
#8  0x0000007fa1ca8c44 in _libssh2_channel_free (channel=channel at entry=0x7fa171c010)
    at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/channel.c:2744
#9  0x0000007fa1ca8f7c in libssh2_channel_free (channel=0x7fa171c010)
    at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/channel.c:2831
#10 0x0000007fa1cb87d0 in scp_recv (session=session at entry=0x7fa16092b0, path=path at entry=0x7fa15e0880 "/tmp/mesh/stats.json",
    sb=sb at entry=0x7fdf4dcba0) at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/scp.c:768
#11 0x0000007fa1cb9458 in libssh2_scp_recv (session=0x7fa16092b0, path=0x7fa15e0880 "/tmp/mesh/stats.json", sb=0x7fa16fe490)
    at /sandbox/colinw/tot/polecat/openwrt/build_dir/target-aarch64_cortex-a53_musl/libssh2-1.11.0-pre1/src/scp.c:799


General Business
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.haxx.se/pipermail/libssh2-devel/attachments/20240205/2c73c152/attachment.htm>


More information about the libssh2-devel mailing list