Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-953

dialyzer crashes with badmatch error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 22.0
    • Fix Version/s: 22.0.3
    • Component/s: dialyzer
    • Labels:
      None

      Description

      Dialyzer crashes with the following error:

      Error: {badmatch,{error,{1,erl_scan,{string,39," | char(),addres"}},1}}
      [{dialyzer,parse_types_and_literals,1,[{file,"dialyzer.erl"},{line,718}]},
       {dialyzer,'-ts/1-fun-1-',4,[{file,"dialyzer.erl"},{line,685}]},
       {dialyzer,field_diff,1,[{file,"dialyzer.erl"},{line,650}]},
       {dialyzer,'-field_diffs/2-lc$^0/1-0-',1,[{file,"dialyzer.erl"},{line,646}]},
       {dialyzer,'-field_diffs/2-lc$^0/1-0-',1,[{file,"dialyzer.erl"},{line,646}]},
       {dialyzer,field_diffs,2,[{file,"dialyzer.erl"},{line,646}]},
       {dialyzer,message_to_string,2,[{file,"dialyzer.erl"},{line,375}]},
       {dialyzer,format_warning,2,[{file,"dialyzer.erl"},{line,297}]}]
      

      which is caused by analyzing this function:

      %%-dialyzer([{no_match, dec_dpd/1}]).
      dec_dpd(Bin) ->
          {Parameter_list, _Bin} = rtps_psm:dec_data(Bin),
          Fun = % Process participant proxy parameters
      	fun(#parameter{id = protocol_version, value = Protocol_version}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{protocol_version = Protocol_version}, Qos, Ld};
      	     (#parameter{id = participant_guid, value = #guid{guid_prefix = Guid_prefix}}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{guid_prefix = Guid_prefix}, Qos, Ld};
      	     (#parameter{id = vendor_id, value = Vendor_id}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{vendor_id = Vendor_id}, Qos, Ld};
      	     (#parameter{id = expects_inline_qos, value = Expects_inline_qos}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{expects_inline_qos = Expects_inline_qos}, Qos, Ld};
      
      	     (#parameter{id = metatraffic_unicast_locator, value = Loc},
      	      {#participant_proxy{metatraffic_unicast_locator_list = Locs} = PP, Qos, Ld})
      		when is_list(Locs) ->
      		  {PP#participant_proxy{metatraffic_unicast_locator_list = [Loc | Locs]}, Qos, Ld};
      	     (#parameter{id = metatraffic_unicast_locator, value = Loc}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{metatraffic_unicast_locator_list = [Loc]}, Qos, Ld};
      
      	     (#parameter{id = metatraffic_multicast_locator, value = Loc},
      	      {#participant_proxy{metatraffic_multicast_locator_list = Locs} = PP, Qos, Ld})
      		when is_list(Locs) ->
      		  {PP#participant_proxy{metatraffic_multicast_locator_list = [Loc | Locs]}, Qos, Ld};
      	     (#parameter{id = metatraffic_multicast_locator, value = Loc}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{metatraffic_multicast_locator_list = [Loc]}, Qos, Ld};
      
      	     (#parameter{id = default_unicast_locator, value = Loc},
      	      {#participant_proxy{default_unicast_locator_list = Locs} = PP, Qos, Ld})
      		when is_list(Locs) ->
      		  {PP#participant_proxy{default_unicast_locator_list = [Loc | Locs]}, Qos, Ld};
      	     (#parameter{id = default_unicast_locator, value = Loc}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{default_unicast_locator_list = [Loc]}, Qos, Ld};
      
      	     (#parameter{id = default_multicast_locator, value = Loc},
      	      {#participant_proxy{default_multicast_locator_list = Locs} = PP, Qos, Ld})
      		when is_list(Locs) ->
      		  {PP#participant_proxy{default_multicast_locator_list = [Loc | Locs]}, Qos, Ld};
      	     (#parameter{id = default_multicast_locator, value = Loc}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{default_multicast_locator_list = [Loc]}, Qos, Ld};
      
      	     (#parameter{id = builtin_endpoint_set, value = Available_builtin_endpoints}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{available_builtin_endpoints = Available_builtin_endpoints}, Qos, Ld};
      	     (#parameter{id = participant_manual_liveliness_count, value = Manual_liveliness_count}, {PP, Qos, Ld}) ->
      		  {PP#participant_proxy{manual_liveliness_count = Manual_liveliness_count}, Qos, Ld};
      
      	   %% Process lease duration
      	     (#parameter{id = participant_lease_duration, value = Lease_duration}, {PP, Qos, _Ld}) ->
      		  {PP, Qos, Lease_duration};
      
      	   %% Process ParticipantBuiltinTopicData
      	     (Parameter, {Particiapnt_proxy, Qos, Lease_duration}) ->
      		  {Particiapnt_proxy, [Parameter | Qos], Lease_duration}
      	  end,
          %% The next line gives a dialyzer error because the
          %% #participant_proxy{} record is created without the proper
          %% values for the fields. The fields are filled in while
          %% processing the parameter list. Ignore this plt warning
          {Reader_proxy, Qos, Lease_duration} = lists:foldl(Fun, {#participant_proxy{}, [], undefined}, Parameter_list),
          #dpd{participant_proxy = Reader_proxy,
      	 participant_builtin_topic_data = Qos,
      	 lease_duration = Lease_duration}.
      

      I had issues with this function before (OTP 21) resulting in a warning from dialyzer and therefor the used -dialyzer directive to suppress the warnings. Clearly the problem is with the empty #participant_proxy record passed in as an argument to lists:foldl while the record is defined as:

      -record(participant_proxy, 
      	{protocol_version :: rtps:protocol_version(),
      	 guid_prefix :: rtps:guid_prefix(),
      	 vendor_id :: rtps:vendor_id(),
      	 expects_inline_qos :: boolean(),
      	 metatraffic_unicast_locator_list :: [rtps:locator()] | undefined,
      	 metatraffic_multicast_locator_list :: [rtps:locator()],
      	 default_unicast_locator_list :: [rtps:locator()] | undefined,
      	 default_multicast_locator_list :: [rtps:locator()],
      	 available_builtin_endpoints :: [rtps:available_builtin_endpoints()],
      	 manual_liveliness_count :: rtps:count()}).
      

      I have no idea if this error is caused by my ignorance or if it is a bug.

      Thank you

        Attachments

        1. erl_crash.dump
          640 kB
        2. rebar3.crashdump
          0.6 kB

          Activity

            People

            Assignee:
            hasse Hans Bolinder
            Reporter:
            schnef Frans Schneider
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: