Dialyzer can't compile map correctly

Jesper Louis Andersen <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAGrdgiUY1CpVcHpBnXmHurf8PW6jLwxhbYknSzPxnMaAC2RRvQ@mail.gmail.com>
Hi OTP team and other interested parties.

While I was building up the enacl application, I have discovered a problem
where I can crash the dialyzer. Attached are two minimized files which
exposes the problem. To compile this I did:

erlc +debug_info *.erl
dialyzer --build_plt --apps kernel stdlib
dialyzer *.beam

and it produces the following IDE (Internal Dialyzer Error):

erlc +debug_info *.erl
dialyzer *.beam
  Checking whether the PLT /home/jlouis/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
=ERROR REPORT==== 16-Dec-2014::01:00:27 ===
Error in process <0.48.0> with exit value:
{{case_clause,map},[{dialyzer_dataflow,find_terminals,1,[{file,"dialyzer_dataflow.erl"},{line,3451}]},{dialyzer_dataflow,find_terminals_list,3,[{file,"dialyzer_dataflow.erl"},{line,3504}]},{dialyzer_dataflow,classify_returns...


dialyzer: Analysis failed with error:
{{case_clause,map},
 [{dialyzer_dataflow,find_terminals,1,
                     [{file,"dialyzer_dataflow.erl"},{line,3451}]},
  {dialyzer_dataflow,find_terminals_list,3,
                     [{file,"dialyzer_dataflow.erl"},{line,3504}]},
  {dialyzer_dataflow,classify_returns,1,
                     [{file,"dialyzer_dataflow.erl"},{line,3443}]},
  {dialyzer_dataflow,'-state__get_warnings/2-fun-0-',7,
                     [{file,"dialyzer_dataflow.erl"},{line,2908}]},
  {lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
  {dialyzer_dataflow,state__get_warnings,2,
                     [{file,"dialyzer_dataflow.erl"},{line,2934}]},
  {dialyzer_dataflow,get_warnings,5,
                     [{file,"dialyzer_dataflow.erl"},{line,142}]},
  {dialyzer_succ_typings,collect_warnings,2,
                         [{file,"dialyzer_succ_typings.erl"},{line,182}]}]}
Last messages in the log cache:
  Reading files and computing callgraph... done in 0.06 secs
  Removing edges... done in 0.01 secs
Makefile:2: recipe for target 'all' failed
make: *** [all] Error 1

I have attached the two culprit files. They have the following sizes:

jlouis@eldar:~/tmp/problem$ wc *.erl
 12  29 211 enacl.erl
 23  36 460 enacl_nif.erl
 35  65 671 total

and I think it may be possible to shrink further down, but I think it is
already small enough to be workable. Do note: while one part is a NIF, you
don't need the underlying C code to break the dialyzer.

The full repository is at:

https://github.com/jlouis/enacl

and the commit ID 23e535fcc23c1 should have the error if you want to look
at the full repository. It does require a properly installed libsodium,
which is not in Debian/Ubuntu for instance, which is why I have tried to
narrow down the problem before reporting it.

I hope this is enough to track down the error, perhaps by looking at the
backtrace and error case alone. Otherwise, please come back to me.

-- 
J.

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
enacl.erl (text/x-erlang, 211 B)
-module(enacl).

%% Public key crypto
-export([
	box_keypair/0
]).

-spec box_keypair() -> #{ atom() => binary() }.
box_keypair() ->
	{PK, SK} = enacl_nif:crypto_box_keypair(),
	#{ public => PK, secret => SK}.
enacl_nif.erl (text/x-erlang, 460 B)
-module(enacl_nif).

%% Public key auth
-export([
	crypto_box_keypair/0
]).

-on_load(init/0).

init() ->
	SoName = filename:join(
		case code:priv_dir(enacl) of
		    {error, bad_name} ->
		        filename:join(filename:dirname(filename:dirname(code:which(?MODULE))), "priv");
		    Dir ->
		        Dir
		end, atom_to_list(?MODULE)),
	erlang:load_nif(SoName, 0).

not_loaded() ->
    error({nif_not_loaded, ?MODULE}).

crypto_box_keypair() -> not_loaded().
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.