Skip to content

SSH connection to RISCV failed. #1769

Open
@chLFF

Description

What happened?

I try to ssh connect to my RISC-V device by python asyncssh, but some how failed.

Python3 asyncssh code:

import asyncio
import asyncssh

if __name__ == "__main__":

    async def run_coro() -> None:
        """ Test coroutine showing the Connection reset by peer bug """

        async with asyncssh.connect("10.0.90.162", port=22, username="device", password="device", known_hosts=None) as conn:
            result = await conn.run("ls /")
            print(" --- ".join(result.stdout.splitlines()))

    asyncio.run(run_coro())

Fail log:

Traceback (most recent call last):
  File "/home/user/workspace/ssh.py", line 13, in <module>
    asyncio.run(run_coro())
  File "/home/user/miniconda3/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/user/miniconda3/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniconda3/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/user/workspace/ssh.py", line 9, in run_coro
    async with asyncssh.connect("10.0.90.162", port=22, username="bianbu", password="bianbu", known_hosts=None) as conn:
  File "/home/user/miniconda3/lib/python3.11/site-packages/asyncssh/misc.py", line 298, in __aenter__
    self._coro_result = await self._coro
                        ^^^^^^^^^^^^^^^^
  File "/home/user/miniconda3/lib/python3.11/site-packages/asyncssh/connection.py", line 8811, in connect
    return await asyncio.wait_for(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/miniconda3/lib/python3.11/asyncio/tasks.py", line 442, in wait_for
    return await fut
           ^^^^^^^^^
  File "/home/user/miniconda3/lib/python3.11/site-packages/asyncssh/connection.py", line 453, in _connect
    await options.waiter
asyncssh.misc.ConnectionLost: Connection lost

What i found?

I use zlib-ng (version 2.2.1) instead of zlib on my RISC-V board. When i turn WITH_RUNTIME_CPU_DETECTION off, everything went well.
But things work fine on ARM. Guess something is wrong with riscv_check_features.

How to reproduce?

Make and install zlib-ng with/without WITH_RUNTIME_CPU_DETECTION. Compare the asyncssh connection using the code above.

  1. WITH_RUNTIME_CPU_DETECTION on -> failed.
    cmake .. -DZLIB_COMPAT=on -DWITH_RUNTIME_CPU_DETECTION=on
-- The following features have been enabled:

 * CMAKE_BUILD_TYPE, Build type: Release (default)
 * WITH_GZFILEOP, Compile with support for gzFile related functions
 * ZLIB_COMPAT, Compile with zlib compatible API
 * ZLIB_ENABLE_TESTS, Build test binaries
 * ZLIBNG_ENABLE_TESTS, Test zlib-ng specific API
 * WITH_SANITIZER, Enable sanitizer support
 * WITH_GTEST, Build gtest_zlib
 * WITH_OPTIM, Build with optimisation
 * WITH_NEW_STRATEGIES, Use new strategies
 * WITH_RUNTIME_CPU_DETECTION, Build with runtime CPU detection
 * WITH_RVV, Build with RVV intrinsics
  1. WITH_RUNTIME_CPU_DETECTION off -> succeed.
    cmake .. -DZLIB_COMPAT=on -DWITH_RUNTIME_CPU_DETECTION=off
-- The following features have been enabled:

 * CMAKE_BUILD_TYPE, Build type: Release (selected)
 * WITH_GZFILEOP, Compile with support for gzFile related functions
 * ZLIB_COMPAT, Compile with zlib compatible API
 * ZLIB_ENABLE_TESTS, Build test binaries
 * ZLIBNG_ENABLE_TESTS, Test zlib-ng specific API
 * WITH_SANITIZER, Enable sanitizer support
 * WITH_GTEST, Build gtest_zlib
 * WITH_OPTIM, Build with optimisation
 * WITH_NEW_STRATEGIES, Use new strategies
 * WITH_RVV, Build with RVV intrinsics

What i want?

World peace.

Activity

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