A minimal snippet to reproduce sftp_aio_wait_read
stall issue.
# clone this repo and move into it
git clone https://gist.github.com/upa/936eb750743fda2b611f4d0262a9a62c jump-sftp-read
cd jump-sftp-read
# Fetch libssh
git clone https://git.libssh.org/projects/libssh.git
# Build the test code
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make -j 10
# Create a file to copy
dd if=/dev/random of=/tmp/test.img bs=1M count=100
# How to run the code
./jump_sftp_read
Usage: ./jump_sftp_read -h HOST -u USER -r REMOTE_FILE [-j JUMP_HOST] [-c CONCURRENT]
-h HOST Remote host
-u USER Username
-r REMOTE_FILE Remote file path to read
-j JUMP_HOST Jump host (optional)
-c CONCURRENT # of concurrent AIO read requests (default: 32)
# Copy without proxyjump
./jump_sftp_read -u $(whoami) -h localhost -r /tmp/test.img
# Copy with proxyjump (this will stall)
./jump_sftp_read -u $(whoami) -h localhost -r /tmp/test.img -j localhost
# Copy with proxyjump without concurrency
./jump_sftp_read -u $(whoami) -h localhost -r /tmp/test.img -j localhost -c 1
Concurrent async read with proxyjump causes stalling at poll.
i1 ~/w/j/build > gdb --args ./jump_sftp_read -u $(whoami) -h localhost -r /tmp/test.img -j localhost
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./jump_sftp_read...
(gdb) run
Starting program: /home/upa/work/jump-sftp-read/build/jump_sftp_read -u upa -h localhost -r /tmp/test.img -j localhost
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Using jump host: localhost
Connecting to upa@localhost...
[New Thread 0x7ffff74006c0 (LWP 2657907)]
Authentication with public key successful
Creating SFTP session...
Opening remote file: /tmp/test.img
Creating local file: test.img
Copying file with 32 concurrent requests...
File size: 104857600 bytes
Progress: 1048576/104857600 bytes (1.0%)^C
Thread 1 "jump_sftp_read" received signal SIGINT, Interrupt.
0x00007ffff771b4cd in __GI___poll (fds=0x5555555c8910, nfds=1, timeout=-1)
at ../sysdeps/unix/sysv/linux/poll.c:29
warning: 29 ../sysdeps/unix/sysv/linux/poll.c: No such file or directory
(gdb) bt
#0 0x00007ffff771b4cd in __GI___poll (fds=0x5555555c8910, nfds=1, timeout=-1)
at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00005555555a4ec7 in ssh_poll_ctx_dopoll ()
#2 0x000055555557d429 in ssh_handle_packets ()
#3 0x000055555557d69d in ssh_handle_packets_termination ()
#4 0x00005555555a1abf in ssh_channel_read_timeout ()
#5 0x0000555555598f7c in sftp_packet_read ()
#6 0x0000555555599d74 in sftp_read_and_dispatch ()
#7 0x000055555559a081 in sftp_recv_response_msg ()
#8 0x000055555559a5ca in sftp_aio_wait_read ()
#9 0x000055555555dd77 in main (argc=9, argv=0x7fffffffe9c8)
at /home/upa/work/jump-sftp-read/jump_sftp_read.c:206