Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad file descriptor on ARM build #217

Closed
inf265 opened this issue Nov 5, 2023 · 6 comments
Closed

Bad file descriptor on ARM build #217

inf265 opened this issue Nov 5, 2023 · 6 comments

Comments

@inf265
Copy link

inf265 commented Nov 5, 2023

Hi,
first of all many thanks for this work, it is amazing, I was able to make a cli in nearby no-time.
I am using standalone version with:

   89  mkdir build
   90  cd build/
   91  cmake .. -DCLI_BuildExamples=ON -DCLI_UseStandaloneAsio=ON
   92  cmake --build .
   93  cd examples/
   94  ./complete

and then telnet to localhost 5000. That works fine on my local PC x86.
Then I did the same on an iMX8 ARM aarch64, the telnet session immediately closes

Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
cli> Terminating this session...
Connection closed by foreign host.

and the process where "complete" is running exits with:

cli> Exception caugth in main: shutdown: Bad file descriptor

What I've seen when compiling on ARM was a warning:

/home/root/cli/include/cli/detail/linuxkeyboard.h:153:13: warning: case label value is less than minimum value for type [-Wswitch-outside-range]
  153 |             case EOF:
      |             ^~~~
[ 83%] Linking CXX executable complete

Any help appreciated...

@inf265
Copy link
Author

inf265 commented Nov 5, 2023

bt.txt

bt_with_debug.txt

I removed the try catch in main and added a gdb backtrace

@daniele77
Copy link
Owner

Hi @inf265 ,

Thank you for using the library and reporting the issue. Although I don't have access to ARM to replicate the problem directly, I have some insights into what you've described.

The warning may be caused by the fact that the library is using:

    auto ch = GetChar();
    ...
    switch(ch) {
       case EOF: ... 

If, in your system, GetChar() returns an unsigned type and EOF has a negative value, it could trigger this warning. However, this would only affect the local session, not the remote one. Therefore, the abrupt closure of your telnet connection is likely not caused by this warning.

The exception in the main is thrown by Session::Disconnect():

    virtual void Disconnect()
    {
        socket.shutdown(asiolib::ip::tcp::socket::shutdown_both);
        socket.close();
    }

This method is called by the exit action of a CliTelnetSession. So, something is causing the telnet session to close, leading to the subsequent exception. Investigating the root cause of the telnet session closing soon after the connection is essential.

You can try using a newer version of the asio library (or try with Boost) if you're using an older one. Additionally, experimenting with different telnet clients or connection options might provide more insights.

Please keep me informed if you gather new information.

@edenbenzimra
Copy link

I had the same issue, solved it by changing the Telnet negotiation mode to Active :)

@daniele77
Copy link
Owner

Should we add in the README.md file that the telnet client must be configured with negotiation = active to successfully connect to the CLI?

@edenbenzimra
Copy link

I apologize I meant passive not active 😄 Maybe you should add it to the read me (windows is ok with both it solved the problem on Linux) also I found that in genericasioremotecli I had to remove the lines 81,84,87 in order to fix the Linux problem (a combination of the two - telnet négociation and removing the lines) I'm havent really figured out why but that is what worked for me 😄

@daniele77
Copy link
Owner

I have fixed an ARM issue with the commit: 2921758
Please, check if this solves your problem and let me know.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants