Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 21.3
    • Fix Version/s: 21.3.1
    • Component/s: ssl
    • Labels:
      None

      Description

      Hello, since updating to 21.3 from 21.2.7 I am getting frequent errors with creating TLS connections.

      This is the error message: Erlang error:

      {:bad_action_from_state_function, {:reply, :undefined, {:error, :timeout}}}
      

      This is the stack trace:

      (stdlib) gen_statem.erl:1290: :gen_statem.parse_actions_reply/7
      (stdlib) gen_statem.erl:1206: :gen_statem.loop_event_actions_list/10
      (ssl) tls_connection.erl:133: :tls_connection.init/1
      (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
      

      I am running an Elixir server by the way, so the code above is Elixir.

      The reason I am posting this here is that I see in the 21.3 release notes there were changes to the TLS application and the errors go away when I revert back to OTP 21.2.7.

        Issue Links

          Activity

          Hide
          nietaki nietaki added a comment -

          It seems to have the same cause as the related issue

          Show
          nietaki nietaki added a comment - It seems to have the same cause as the related issue
          Hide
          ingela Ingela Anderton Andin added a comment - - edited

          This is a little symptom treating, I will look into the real issue more tomorrow, but it could be a workaround atleast.

          diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
          index ad81288f64..1b90450edc 100644
          --- a/lib/ssl/src/ssl_connection.erl
          +++ b/lib/ssl/src/ssl_connection.erl
          @@ -1310,6 +1310,8 @@ handle_common_event({timeout, handshake}, close, _StateName, #state{start_or_rec
               {stop_and_reply,
                {shutdown, user_timeout},
                {reply, StartFrom, {error, timeout}}, State#state{start_or_recv_from = undefined}};
          +handle_common_event({timeout, recv}, timeout, StateName, #state{start_or_recv_from = undefined} = State, _) ->
          +    {next_state, StateName, State};
           handle_common_event({timeout, recv}, timeout, StateName, #state{start_or_recv_from = RecvFrom} = State, _) ->
               {next_state, StateName, State#state{start_or_recv_from = undefined,
                                                   bytes_to_read = undefined}, [{reply, RecvFrom, {error, timeout}}]};
          
          

          Show
          ingela Ingela Anderton Andin added a comment - - edited This is a little symptom treating, I will look into the real issue more tomorrow, but it could be a workaround atleast. diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl index ad81288f64..1b90450edc 100644 --- a/lib/ssl/src/ssl_connection.erl +++ b/lib/ssl/src/ssl_connection.erl @@ -1310,6 +1310,8 @@ handle_common_event({timeout, handshake}, close, _StateName, #state{start_or_rec {stop_and_reply, {shutdown, user_timeout}, {reply, StartFrom, {error, timeout}}, State#state{start_or_recv_from = undefined}}; +handle_common_event({timeout, recv}, timeout, StateName, #state{start_or_recv_from = undefined} = State, _) -> + {next_state, StateName, State}; handle_common_event({timeout, recv}, timeout, StateName, #state{start_or_recv_from = RecvFrom} = State, _) -> {next_state, StateName, State#state{start_or_recv_from = undefined, bytes_to_read = undefined}, [{reply, RecvFrom, {error, timeout}}]};
          Hide
          ingela Ingela Anderton Andin added a comment - - edited

          Here is the real patch same as ERL-884

          diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
          index 3229004c9d..aa7b501831 100644
          --- a/lib/ssl/src/tls_connection.erl
          +++ b/lib/ssl/src/tls_connection.erl
          @@ -224,6 +224,22 @@ next_event(StateName, Record, State, Actions) ->
           
           %%% TLS record protocol level application data messages 
           
          +handle_protocol_record(#ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, StateName, 
          +                       #state{start_or_recv_from = From,
          +                              socket_options = #socket_options{active = false}} = State0) when From =/= undefined ->
          +    case ssl_connection:read_application_data(Data, State0) of
          +       {stop, _, _} = Stop->
          +            Stop;
          +       {Record, #state{start_or_recv_from = Caller} = State1} ->
          +            TimerAction = case Caller of
          +                              undefined -> %% Passive recv complete cancel timer
          +                                  [{{timeout, recv}, infinity, timeout}];
          +                              _ ->
          +                                  []
          +                          end,
          +            {next_state, StateName, State, Actions} = next_event(StateName, Record, State1, TimerAction), 
          +            ssl_connection:hibernate_after(StateName, State, Actions)
          +    end;
           handle_protocol_record(#ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, StateName, State0) ->
               case ssl_connection:read_application_data(Data, State0) of
                  {stop, _, _} = Stop->
          
          

          Show
          ingela Ingela Anderton Andin added a comment - - edited Here is the real patch same as ERL-884 diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl index 3229004c9d..aa7b501831 100644 --- a/lib/ssl/src/tls_connection.erl +++ b/lib/ssl/src/tls_connection.erl @@ -224,6 +224,22 @@ next_event(StateName, Record, State, Actions) -> %%% TLS record protocol level application data messages +handle_protocol_record(#ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, StateName, + #state{start_or_recv_from = From, + socket_options = #socket_options{active = false}} = State0) when From =/= undefined -> + case ssl_connection:read_application_data(Data, State0) of + {stop, _, _} = Stop-> + Stop; + {Record, #state{start_or_recv_from = Caller} = State1} -> + TimerAction = case Caller of + undefined -> %% Passive recv complete cancel timer + [{{timeout, recv}, infinity, timeout}]; + _ -> + [] + end, + {next_state, StateName, State, Actions} = next_event(StateName, Record, State1, TimerAction), + ssl_connection:hibernate_after(StateName, State, Actions) + end; handle_protocol_record(#ssl_tls{type = ?APPLICATION_DATA, fragment = Data}, StateName, State0) -> case ssl_connection:read_application_data(Data, State0) of {stop, _, _} = Stop->
          Hide
          ingela Ingela Anderton Andin added a comment -

          Will be released soon

          Show
          ingela Ingela Anderton Andin added a comment - Will be released soon
          Hide
          shdblowers Steven Blowers added a comment -

          Thank you for the fix @ingela

          Show
          shdblowers Steven Blowers added a comment - Thank you for the fix @ingela

            People

            • Assignee:
              otp_team_ps Team PS
              Reporter:
              shdblowers Steven Blowers
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development