Skip to content

In OTP 26, Erlang's SSH client fails to connect if it receives an {'EXIT', Pid, normal} message from an unrelated process. #8223

Closed
@matthiasl

Description

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:

%% Throwaway to debug SSH problems
%%
%% The Erlang SSH library doesn't seem to like old 'EXIT' messages left
%% lying around in the message queue. The mssage gets matched in
%% ssh_connection_handler:handshake/3; it looks like this behaviour was
%% added by 1963f9501
%%
%% I can reproduce the problem in otp_src_26.0.2
%% I cannot reproduce the problem in otp_src_23.1
%%
%%
-module(test_ssh_crash).

-export([works/0, fails/0]).

works() ->
    crypto:start(),
    ssh:start(),
    {ok, _SSH} = ssh:connect("localhost", 22,
			    [{user, "bogus"}, {password, "bogus"},
			     {silently_accept_hosts, true}]).

fails() ->
    self() ! {'EXIT', self(), normal},
    works().

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.

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:PSAssigned to OTP team PS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions