[erlang-bugs] Dialyzer bug: incorrect duplicate modules

Maxim Treskin <>
Thu Mar 21 07:40:21 CET 2013


Hello

At Montenegro Erlang Hackaton (
http://lanyrd.com/2013/herceg-novi-erlang-meetup/ , there were only two
people, unfortunately ) we found incorrect behaviour of Dialyzer.

Our project erroneous had a duplicated modules with the same name, but
different content. When we check it with dialyzer it show me something like
that:

Duplicate modules: [["/var/tmp/myproj/apps/myproj/ebin/psc_operate.beam",

 "/var/tmp/myproj/deps/somedep/ebin/amp_common_utils.beam"]]

Obviously it is not the same modules. So I had to search this bug and find
strange behaviour in dialyzer. Function lists:zip/2 called with two list,
where first is reversed list of modules as atom, and second is list of
filepaths for modules. And this list not always contains correspond
elements. Module with name some_module1 can be has filename like
abc_module55.beam. This is the cause of error.

This bug exists in R15B02 and R16.

I wrote such patch to fix bug, but I don't know whether this is solution or
not, though it works fine.

--- /opt/r16a/lib/dialyzer-2.5.4/src/dialyzer_analysis_callgraph.erl
 2013-01-31 12:55:53.210402846 +0700
+++ dialyzer_pa/dialyzer_analysis_callgraph.erl 2013-03-21
13:20:46.794991889 +0700
@@ -255,10 +255,18 @@
   CServer2 = dialyzer_codeserver:set_next_core_label(NextLabel, CServer),
   case Failed =:= [] of
     true ->
-      NewFiles = lists:zip(lists:reverse(Modules), Files),
+      %% Modules and Files have not the same order, so it is meaningless
to zip it
+      %% NewFiles = lists:zip(lists:reverse(Modules), Files),
+
       ModDict =
-        lists:foldl(fun({Mod, F}, Dict) -> dict:append(Mod, F, Dict) end,
-                    dict:new(), NewFiles),
+        lists:foldl(fun(F, Dict) ->
+                        ModFile = lists:last(filename:split(F)),
+                        Mod = filename:basename(ModFile, ".beam"),
+                        dict:append(Mod, F, Dict) end,
+                    dict:new(), Files),
+      %% ModDict =
+      %%   lists:foldl(fun({Mod, F}, Dict) -> dict:append(Mod, F, Dict)
end,
+      %%               dict:new(), NewFiles),
       check_for_duplicate_modules(ModDict);
     false ->
       Msg = io_lib:format("Could not scan the following file(s): ~p",


-- 
Max Treskin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20130321/19641a45/attachment.html>


More information about the erlang-bugs mailing list