New analysis case for Dialyzer ?

Tobias Lindahl tobias.lindahl@REDACTED
Mon Apr 11 11:05:05 CEST 2005

Hi Mickael,

Thanks for the report. We are really interested in getting suggestions on
what Dialyzer should find but currently doesn't.

I agree that this should be found by Dialyzer, and hopefully this will be
solved. The reason it is not found is an old issue that has been discussed
before, but it might be worth mentioning again. In

> *   TS = To#psock.s,

the problem is that accessing a field of a record using the .-notation is
not a guarantee that the variable is an instance of the record. It
compiles in the same way as erlang:element/2, so the only limitation on TO
in your example is that it is a tuple and that it is sufficiently big to
take the element corresponding to the record field s from it.

The type signature of erlang:send/2 (or !) is:

send(pid() | port() | atom() | {atom(), atom()}, any()) -> any()

The information that the first operand is a tuple will not yield a
discrepancy report, since it might succeed. (If something can succeed
Dialyzer currently reports nothing to avoid false positives.)

However, if the use of To had been protected by an is_record-guard, or if
the more safe construct

#psock{s=TS} = TO

Dialyzer would have reported the discrepancy since it would have had more
information about TO.


On Sat, 9 Apr 2005, Mickael Remond wrote:

> Hello,
> Here is a piece of code that contains a bug: (* are marking the
> interesting lines):
> -=-=-=-
> *   TS = To#psock.s,
>      case From#psock.mode of
>          expectheaders ->
>              SSL = nossl,
>              case yaws:http_get_headers(From#psock.s, SSL) of
>                  {R, H0} ->
>                      ?Debug("R = ~p~n",[R]),
>                      RStr =
>                          if
>                              %% FIXME handle bad_request here
>                              record(R, http_response) ->
>                                  yaws_api:reformat_response(R);
>                              record(R, http_request) ->
> *                               To ! {cli2srv, R#http_request.method,
>                              },
>                                  yaws_api:reformat_request(
>                                    rewrite_path(R, From#psock.prefix))
>                          end,
> -=-=-=-
> The To variable is used as a record, but later on is used as a Pid.
> I try to analyse the code with Dialyzer, but it did not suspect the
> problem. Maybe analysis has been extended in the latest version of
> Dialyzer (I did not try the brand new one), but I thought that actually
> this piece of code might help the HiPE team.
> Cheers,
> --
> Mickaël Rémond

More information about the erlang-questions mailing list