-
Notifications
You must be signed in to change notification settings - Fork 3k
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
In OTP 26, Erlang's SSH client fails to connect if it receives an {'EXIT', Pid, normal} message from an unrelated process. #8223
Comments
I analysed the problem a bit and it is indeed a bug introduced by 1963f95 as @matthiasl guessed. otp/lib/ssh/src/ssh_connection_handler.erl Lines 490 to 509 in d13fe87
The problem is receiving an I was wondering why this is even done, since the process here is the process calling It turns out that this is because
|
This is done because you want to gracefully shut down However, this is a problem because you don't know if you received your EXIT messages before or after spawning a connection handler. I think we should move trapping exits to
|
@MarkoMin hm, I think you got some of it wrong, it's not quite like that... But hard to explain in just a few words 🤷♀️ In a nutshell, receiving and handling (And no, the user process doesn't get its |
Aham, I see where I got it wrong, I looked only from the client side... The solution now makes complete sense, but there is one more process to think about (except Parent) when receiving EXITs, and that is Socket process (IIRC sockets are implemented as processes), because process that traps exits is the controlling process of the socket. I'm not sure if socket process sends EXIT messages to the controlling process, but that is something that one should be aware of. |
Off the top of my head, I have no idea 😅 Maybe @u3s knows? *poke* |
I thought that was the purpose (or one of them) for handling EXIT messages (to handle failing socket) in I plan to have deeper look on code later. |
Hm, I don't know, now that you say that... I thought it was to act on the death of the acceptor process, since with |
@u3s @MarkoMin this is what I found out. Take this with a grain of salt though, I may easily have missed something there. Regarding sockets and links, mainly by playing around in the shell. (I set
Regarding
If this is all correct, it would mean that my fix in #8226 is sound. |
So what happens when port exits unexpectedly and we're trapping exits? Wouldn't that just be ignored if we're just matching on parent exit? |
Yes. I can provide for that easily if it is wanted, ie I'm not against it 🤷♀️ I'll just point out that this will then work somewhat differently depending on whether the |
The socket backend is suppose to behave the same as the inet-backend and will not become default until it does. |
Hi Ingela 👋 While I believe that my PR solves the issue described by the OP, it may be possible that it thereby fosters some possible structural errors in the |
Thanks for the fix. Building OTP from ea38c67 (in https://github.com/Maria-12648430/otp.git) completely solves the problem for me. The minimal testcase I posted here now behaves as expected, as does the live code which triggered the debugging. Particularly interesting to read the discussion about the code being called from two contexts. |
Co-authored-by: Maria Scott <[email protected]> Co-authored-by: Jan Uhlig <[email protected]>
Co-authored-by: Maria Scott <[email protected]> Co-authored-by: Jan Uhlig <[email protected]>
…46/OTP-19247' into maint * kuba/ssh/receive_EXIT_fix_options_construct_fix/OTP-19246/OTP-19247: ssh: text supervision diagram fix ssh: append {active, false} to option list ssh: fix Opts creation in ssh_acceptor:listen ssh: don't receive EXIT message on client side ssh: missing subsys_sup to connection_sup rename ssh: code formatting ssh: GH-8223 'EXIT' issue testcases
…x/OTP-19246/OTP-19247' into maint * kuba/maint-25/ssh/receive_EXIT_fix_options_construct_fix/OTP-19246/OTP-19247: ssh: text supervision diagram fix ssh: append {active, false} to option list ssh: fix Opts creation in ssh_acceptor:listen ssh: don't receive EXIT message on client side ssh: missing subsys_sup to connection_sup rename ssh: code formatting ssh: GH-8223 'EXIT' issue testcases
issue is fixed with merge of #8854. thanks for discussion which happened in relation to that issue! I hope, they will soon materialize in a next PR. |
…x/OTP-19246/OTP-19247' into maint-26 * kuba/maint-25/ssh/receive_EXIT_fix_options_construct_fix/OTP-19246/OTP-19247: ssh: text supervision diagram fix ssh: append {active, false} to option list ssh: fix Opts creation in ssh_acceptor:listen ssh: don't receive EXIT message on client side ssh: missing subsys_sup to connection_sup rename ssh: code formatting ssh: GH-8223 'EXIT' issue testcases # Conflicts: # lib/ssh/src/ssh_connection_handler.erl # lib/ssh/src/ssh_info.erl # lib/ssh/test/ssh_connection_SUITE.erl # lib/ssh/test/ssh_protocol_SUITE.erl
…x/OTP-19246/OTP-19247' into maint-25 * kuba/maint-25/ssh/receive_EXIT_fix_options_construct_fix/OTP-19246/OTP-19247: ssh: text supervision diagram fix ssh: append {active, false} to option list ssh: fix Opts creation in ssh_acceptor:listen ssh: don't receive EXIT message on client side ssh: missing subsys_sup to connection_sup rename ssh: code formatting ssh: GH-8223 'EXIT' issue testcases # Conflicts: # lib/ssh/src/ssh_connection_handler.erl # lib/ssh/src/ssh_info.erl # lib/ssh/test/ssh_protocol_SUITE.erl
…x/OTP-19246/OTP-19247' into maint-27 * kuba/maint-25/ssh/receive_EXIT_fix_options_construct_fix/OTP-19246/OTP-19247: ssh: text supervision diagram fix ssh: append {active, false} to option list ssh: fix Opts creation in ssh_acceptor:listen ssh: don't receive EXIT message on client side ssh: missing subsys_sup to connection_sup rename ssh: code formatting ssh: GH-8223 'EXIT' issue testcases # Conflicts: # lib/ssh/src/ssh_connection_handler.erl # lib/ssh/src/ssh_info.erl # lib/ssh/test/ssh_connection_SUITE.erl # lib/ssh/test/ssh_protocol_SUITE.erl
Describe the bug
If there’s an {‘EXIT’, _, normal} message in a process’ mailbox when calling ssh:connect(), the SSH library terminates without attempting to create a connection.
To Reproduce
Complete test case here:
Expected behavior
On a machine with an SSH server, both works() and fails() should terminate with an authentication failure.
Actual behaviour is that fails() exits prematurely.
(And, if you replace the user/password with something valid, then works() will correctly connect to the SSH server, whereas fails() will not succeed with the connection.)
Affected versions
Seen in OTP 25 and OTP 26.
Bug possibly introduced in 1963f95
Additional context
A workaround is to launch SSH from a process where you're sure you can't get any 'EXIT' messages.
The text was updated successfully, but these errors were encountered: