Skip to content

_libssh2_transport_read block forever on Android with OpenSSL #694

Closed

Description

@Zhumengshu

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

  1. changed the title [-]_libssh2_transport_read block forever in Android with OpenSSL[/-] [+]_libssh2_transport_read block forever on Android with OpenSSL[/+] on Apr 29, 2022
  2. bk138 commented on Jun 18, 2022

    @bk138

    @Zhumengshu Am having the same issue on Android w/ LibreSSL - did you try any other SSL backend?

  3. bk138 commented on Jun 20, 2022

    @bk138

    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.

  4. Zhumengshu commented on Jun 21, 2022

    @Zhumengshu
    Author

    @bk138 Great , I will try it again , Thanks a lot .

  5. willco007 commented on Jun 23, 2022

    @willco007
    Member

    @Zhumengshu have you had a chance to test this PR?

  6. bk138 commented on Sep 5, 2022

    @bk138

    @Zhumengshu have you had a chance to test this PR?

    @Zhumengshu friendly ping :-)

  7. willco007 commented on Oct 28, 2022

    @willco007
    Member

    Would like to land the fix for this if we can get confirmation this is good to go.

  8. bk138 commented on Oct 28, 2022

    @bk138

    @willco007 you have one confirmation that #712 fixes this issue: I ran into the same problem as #694 and #712 fixed it for me ;-)

  9. added a commit that references this issue on Mar 7, 2023
    2602b71
  10. added a commit that references this issue on Mar 8, 2023
    9ad1258
  11. added a commit that references this issue on Jul 14, 2024
    f754787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions