Repository navigation
Description
Describe the bug
A clear and concise description of what the bug is.
_libssh2_transport_read block forever on Android with openssl
But everything ok on Windows
To Reproduce
Steps to reproduce the behavior.
run libss2 in android
A recipe or example code that reproduces the problem? A stack trace from a crash
Expected behavior
A clear and concise description of what you expected to happen.
Version (please complete the following information):
- OS and version: [e.g. iOS, macOS, Windows, Linux (distro)]
- libssh2 version: [e.g. 1.10.0]
- crypto backend: [OpenSSL, MbedTLS, Libgcrypt, LibreSSL, WinCNG, OS400, WolfSSL, None]
libssh2 1.10
android
OpenSSL
Additional context
Add any other context about the problem here.
I/native/: libssh2_channel_exec
I/libssh2: starting request(exec) on channel 0/0, message=uptime
I/libssh2: Sent 80/80 bytes at 0xb400007cddbcdb48
I/libssh2: Looking for packet of type: 99
I/libssh2: Looking for packet of type: 100
I/libssh2: Recved 112/16384 bytes to 0xb400007cddbc9b08+0
I/libssh2: Packet type 93 received, length=9
I/libssh2: Window adjust for channel 0/0, adding 2097152 bytes, new window_size=2097152
I/libssh2: Packet type 99 received, length=5
I/libssh2: Looking for packet of type: 99
I/native/: libssh2_channel_read begin
I/libssh2: libssh2_channel_window_read_ex 2159
I/libssh2: _libssh2_channel_read 2171
I/libssh2: channel_read() wants 16384 bytes from channel 0/0 stream #0
I/libssh2: channel_read 2001
I/libssh2: _libssh2_transport_read
I/libssh2: Recved 128/16384 bytes to 0xb400007cddbc9b08+0
I/libssh2: Packet type 94 received, length=80
I/libssh2: increasing read_avail by 71 bytes to 71/2097152
I/libssh2: _libssh2_transport_read 94
I/libssh2: _libssh2_transport_read
I/libssh2: Recved 48/16384 bytes to 0xb400007cddbc9b08+0
I/libssh2: Packet type 96 received, length=5
I/libssh2: EOF received for channel 0/0
I/libssh2: _libssh2_transport_read 96
I/libssh2: _libssh2_transport_read
I/libssh2: Recved 128/16384 bytes to 0xb400007cddbc9b08+0
I/libssh2: Packet type 98 received, length=25
I/libssh2: Channel 0 received request type exit-status (wr 0)
I/libssh2: Exit status 0 received for channel 0/0
I/libssh2: _libssh2_transport_read 98
I/libssh2: _libssh2_transport_read
I/libssh2: Packet type 97 received, length=5
I/libssh2: Close received for channel 0/0
I/libssh2: _libssh2_transport_read 97
I/libssh2: _libssh2_transport_read
now block forever ,never return .
Activity
[-]_libssh2_transport_read block forever in Android with OpenSSL[/-][+]_libssh2_transport_read block forever on Android with OpenSSL[/+]bk138 commentedon Jun 18, 2022
@Zhumengshu Am having the same issue on Android w/ LibreSSL - did you try any other SSL backend?
bk138 commentedon Jun 20, 2022
OK, found the reason after some debugging. Background: I have an Android app that builds LibreSSL and libssh2 from source; i.e. the one single CMakeLists.txt pulls in libressl's and libssh2's CMakeLists.txt via
add_subdirectory, see here.To make libssh2's CMake find the OpenSSL implementation offered by LibreSSL, some variables for FindSSL.cmake to consume are set, basically where to find OpenSSL in a non-standard place.
Now, as this is one big CMake build system, there's only one configure phase and one build phase, i.e. when libssh2 is configured, there is no library built yet, including LibreSSL.
Finally, what then actually breaks is https://github.com/libssh2/libssh2/blob/master/src/CMakeLists.txt#L347 which tries to link against a libssl.a which is not yet built, failing the test and ending up with HAVE_DISABLED_NONBLOCKING in libssh2_config.h.
I'll prepare a PR to fix this.
Zhumengshu commentedon Jun 21, 2022
@bk138 Great , I will try it again , Thanks a lot .
willco007 commentedon Jun 23, 2022
@Zhumengshu have you had a chance to test this PR?
bk138 commentedon Sep 5, 2022
@Zhumengshu friendly ping :-)
willco007 commentedon Oct 28, 2022
Would like to land the fix for this if we can get confirmation this is good to go.
bk138 commentedon Oct 28, 2022
@willco007 you have one confirmation that #712 fixes this issue: I ran into the same problem as #694 and #712 fixed it for me ;-)
cmake: use only needed socket libs when checking non-blocking sockets
cmake: use only needed socket libs when checking non-blocking sockets (…
cmake: use only needed socket libs when checking non-blocking sockets (…