erlang / rebar3

Erlang build tool that makes it easy to compile and test Erlang applications and releases.
http://www.rebar3.org
Apache License 2.0
1.7k stars 518 forks source link

rebar crashes on dialyzer option exclude_mods #2005

Closed josefs closed 5 years ago

josefs commented 5 years ago

Pre-Check

I'm happy to provide more feedback if needed in order to help resolve this question.

Environment

$ rebar3 report dialyzer
Rebar3 report
 version 3.7.2
 generated at 2019-01-27T15:14:09+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: dialyzer
Entered as:
  dialyzer
-----------------
Operating System: x86_64-unknown-linux-gnu
ERTS: Erlang/OTP 21 [erts-10.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Root Directory: /nix/store/12871pfs4dib6bvwmjx6phxmbymwd2r7-erlang-21.2.3/lib/erlang
Library directory: /nix/store/12871pfs4dib6bvwmjx6phxmbymwd2r7-erlang-21.2.3/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.6.0
certifi: 2.3.1
cf: 0.2.2
common_test: 1.16.1
compiler: 7.3.1
crypto: 4.4
cth_readable: 1.4.2
dialyzer: 3.3.1
edoc: 0.9.4
erlware_commons: 1.3.0
eunit: 2.3.7
eunit_formatters: 0.5.0
getopt: 1.0.1
hex_core: 0.2.0
hipe: 3.18.2
inets: 7.0.3
kernel: 6.2
providers: 1.7.0
public_key: 1.6.4
relx: 3.27.0
sasl: 3.3
snmp: 5.2.12
ssl_verify_fun: 1.1.3
stdlib: 3.7
syntax_tools: 2.1.6
tools: 3.0.2

-----------------
Escript path: undefined
Providers:
  app_discovery as clean compile compile cover ct deps dialyzer do edoc escriptize eunit generate get-deps help install install_deps list lock new path pkgs release relup report repos shell state tar tree unlock update upgrade upgrade upgrade version xref 

Current behaviour

We're using rebar for the Gradualizer project. I've encountered a situation where rebar crashes on us.

In order to reproduce, do the following:

git clone https://github.com/josefs/Gradualizer
cd Gradualizer
git branch rebar_crash
rebar3 dialyzer

The culprit seems to be that I've added the following line to rebar.config: {dialyzer, [exclude_mods, ["gradualizer_prelude"]]}.

Is there any way of achieving that without rebar crashing on me?

DEBUG=1 rebar3 dialyzer
===> 21.2.3 satisfies the requirement for minimum OTP version 19.0
===> Evaluating config script "/home/josef/repos/Gradualizer/_build/default/plugins/covertool/rebar.config.script"
===> Expanded command sequence to be run: [{default,app_discovery},
                                                  {default,install_deps},
                                                  {default,lock},
                                                  {default,compile},
                                                  {default,dialyzer}]
===> Provider: {default,app_discovery}
===> 21.2.3 satisfies the requirement for minimum OTP version 19.0
===> Provider: {default,install_deps}
===> Verifying dependencies...
===> Provider: {default,lock}
===> Provider: {default,compile}
===> run_hooks("/home/josef/repos/Gradualizer", pre_hooks, compile) -> no hooks defined

===> sh info:
    cwd: "/home/josef/repos/Gradualizer"
    cmd: mkdir -p /home/josef/repos/Gradualizer/_build/default/lib/gradualizer/ebin

===>    opts: [{use_stdout,false},abort_on_error]

===> Port Cmd: mkdir -p /home/josef/repos/Gradualizer/_build/default/lib/gradualizer/ebin
Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof]

===> sh info:
    cwd: "/home/josef/repos/Gradualizer"
    cmd: cp -Rp /home/josef/repos/Gradualizer/ebin/absform.beam /home/josef/repos/Gradualizer/ebin/constraints.beam /home/josef/repos/Gradualizer/ebin/gradualizer.app /home/josef/repos/Gradualizer/ebin/gradualizer.beam /home/josef/repos/Gradualizer/ebin/gradualizer_cli.beam /home/josef/repos/Gradualizer/ebin/gradualizer_db.beam /home/josef/repos/Gradualizer/ebin/gradualizer_file_utils.beam /home/josef/repos/Gradualizer/ebin/gradualizer_lib.beam /home/josef/repos/Gradualizer/ebin/rebar_prv_gradualizer.beam /home/josef/repos/Gradualizer/ebin/test /home/josef/repos/Gradualizer/ebin/ty.beam /home/josef/repos/Gradualizer/ebin/typechecker.beam /home/josef/repos/Gradualizer/ebin/typechecker2.beam /home/josef/repos/Gradualizer/ebin/typelib.beam "/home/josef/repos/Gradualizer/_build/default/lib/gradualizer/ebin"

===>    opts: [{use_stdout,false},abort_on_error]

===> Port Cmd: cp -Rp /home/josef/repos/Gradualizer/ebin/absform.beam /home/josef/repos/Gradualizer/ebin/constraints.beam /home/josef/repos/Gradualizer/ebin/gradualizer.app /home/josef/repos/Gradualizer/ebin/gradualizer.beam /home/josef/repos/Gradualizer/ebin/gradualizer_cli.beam /home/josef/repos/Gradualizer/ebin/gradualizer_db.beam /home/josef/repos/Gradualizer/ebin/gradualizer_file_utils.beam /home/josef/repos/Gradualizer/ebin/gradualizer_lib.beam /home/josef/repos/Gradualizer/ebin/rebar_prv_gradualizer.beam /home/josef/repos/Gradualizer/ebin/test /home/josef/repos/Gradualizer/ebin/ty.beam /home/josef/repos/Gradualizer/ebin/typechecker.beam /home/josef/repos/Gradualizer/ebin/typechecker2.beam /home/josef/repos/Gradualizer/ebin/typelib.beam "/home/josef/repos/Gradualizer/_build/default/lib/gradualizer/ebin"
Port Opts: [exit_status,{line,16384},use_stdio,stderr_to_stdout,hide,eof]

===> Compiling gradualizer
===> run_hooks("/home/josef/repos/Gradualizer", pre_hooks, compile) -> no hooks defined

===> run_hooks("/home/josef/repos/Gradualizer", pre_hooks, erlc_compile) -> no hooks defined

===> erlopts [debug_info]
===> files to compile ["/home/josef/repos/Gradualizer/src/constraints.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_cli.erl",
                              "/home/josef/repos/Gradualizer/src/typechecker.erl",
                              "/home/josef/repos/Gradualizer/src/ty.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_lib.erl",
                              "/home/josef/repos/Gradualizer/src/typelib.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_db.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_file_utils.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_bin.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer.erl",
                              "/home/josef/repos/Gradualizer/src/gradualizer_prelude.erl",
                              "/home/josef/repos/Gradualizer/src/absform.erl",
                              "/home/josef/repos/Gradualizer/src/rebar_prv_gradualizer.erl"]
===>      Compiled absform.erl
===>      Compiled typelib.erl
===>      Compiled gradualizer_db.erl
===>      Compiled constraints.erl
src/ty.erl:6: Warning: export_all flag enabled - all functions will be exported

===>      Compiled ty.erl
===>      Compiled gradualizer.erl
===>      Compiled rebar_prv_gradualizer.erl
===>      Compiled gradualizer_file_utils.erl
===>      Compiled gradualizer_lib.erl
===>      Compiled gradualizer_cli.erl
src/typechecker.erl:27: Warning: export_all flag enabled - all functions will be exported

===>      Compiled typechecker.erl
===> run_hooks("/home/josef/repos/Gradualizer", post_hooks, erlc_compile) -> no hooks defined

===> run_hooks("/home/josef/repos/Gradualizer", pre_hooks, app_compile) -> no hooks defined

===> run_hooks("/home/josef/repos/Gradualizer", post_hooks, app_compile) -> no hooks defined

===> run_hooks("/home/josef/repos/Gradualizer", post_hooks, compile) -> no hooks defined

===> run_hooks("/home/josef/repos/Gradualizer", post_hooks, compile) -> no hooks defined

===> Provider: {default,dialyzer}
===> Dialyzer starting, this may take a while...
===> Updating plt...
===> Resolving files...
===> kernel modules: [user_sup,local_udp,inet_tcp,inet6_tcp,group,
                             global_group,gen_tcp,gen_sctp,disk_log_sup,
                             disk_log_1,wrap_log_reader,user,standard_error,
                             pg2,logger_server,logger_handler_watcher,
                             logger_formatter,logger,inet_db,
                             hipe_unified_loader,file_server,file_io_server,
                             error_logger,error_handler,erl_signal_handler,
                             erl_boot_server,disk_log_server,code_server,
                             application_starter,application_master,
                             application_controller,rpc,os,logger_filters,
                             kernel_refc,inet_res,inet_hosts,inet_dns,dist_ac,
                             raw_file_io_list,raw_file_io_delayed,
                             raw_file_io_compressed,net,logger_backend,
                             inet_tcp_dist,inet6_tcp_dist,inet,heart,erl_epmd,
                             seq_trace,raw_file_io_inflate,
                             raw_file_io_deflate,ram_file,inet_parse,
                             inet_gethost_native,file,code,user_drv,
                             raw_file_io_raw,logger_config,kernel_config,
                             inet_config,erts_debug,disk_log,logger_std_h,
                             logger_simple_h,logger_disk_log_h,global_search,
                             auth,group_history,erl_reply,net_kernel,kernel,
                             global,erl_ddll,dist_util,net_adm,
                             logger_h_common,erl_distribution,application,
                             raw_file_io,logger_sup,local_tcp,inet_udp,
                             inet_sctp,inet6_udp,inet6_sctp,gen_udp]
===> stdlib modules: [zip,dets_sup,timer,supervisor,proc_lib,io_lib,
                             gen_server,filelib,file_sorter,erl_tar,erl_error,
                             dets_server,calendar,beam_lib,sys,sofs,sets,qlc,
                             proplists,ordsets,maps,lists,gb_trees,gb_sets,
                             eval_bits,ets,erl_expand_records,erl_bits,
                             digraph_utils,dets_utils,dets,c,shell_default,
                             rand,qlc_pt,orddict,io_lib_fread,io_lib_format,
                             gen_event,escript,erl_lint,edlin_expand,dict,
                             base64,unicode,supervisor_bridge,slave,re,queue,
                             filename,erl_parse,erl_compile,erl_abstract_code,
                             win32reg,uri_string,string,erl_posix_msg,math,
                             log_mf_h,error_logger_tty_h,error_logger_file_h,
                             digraph,io_lib_pretty,dets_v9,binary,array,
                             unicode_util,shell,pool,otp_internal,
                             erl_internal,erl_eval,random,ms_transform,
                             gen_statem,gen_fsm,gen,erl_scan,edlin,io,
                             erl_anno,erl_pp,epp]
===> erts modules: [prim_zip,otp_ring0,zlib,prim_buffer,
                           erts_literal_area_collector,
                           erts_dirty_process_signal_handler,erts_code_purger,
                           erl_tracer,erl_prim_loader,counters,atomics,
                           prim_inet,init,prim_file,erlang,prim_eval,
                           erts_internal,persistent_term]
===> crypto modules: [crypto_ec_curves,crypto]
===> Uncaught error in rebar_core. Run with DEBUG=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: badarg
===> Stack trace to the error location:
[{erlang,'++',[true,[]],[]},
 {rebar_prv_dialyzer,get_files,5,
                     [{file,"/opt/rebar3-3.7.2/src/rebar_prv_dialyzer.erl"},
                      {line,222}]},
 {rebar_prv_dialyzer,do_update_proj_plt,3,
                     [{file,"/opt/rebar3-3.7.2/src/rebar_prv_dialyzer.erl"},
                      {line,188}]},
 {rebar_prv_dialyzer,do,2,
                     [{file,"/opt/rebar3-3.7.2/src/rebar_prv_dialyzer.erl"},
                      {line,153}]},
 {rebar_prv_dialyzer,do,1,
                     [{file,"/opt/rebar3-3.7.2/src/rebar_prv_dialyzer.erl"},
                      {line,93}]},
 {rebar_core,do,2,[{file,"/opt/rebar3-3.7.2/src/rebar_core.erl"},{line,154}]},
 {rebar3,run_aux,2,[{file,"/opt/rebar3-3.7.2/src/rebar3.erl"},{line,178}]},
 {rebar3,main,1,[{file,"/opt/rebar3-3.7.2/src/rebar3.erl"},{line,66}]}]
===> When submitting a bug report, please include the output of `rebar3 report "your command"`

Expected behaviour

I expect rebar to run dialyzer as usual but pass the parameter exclude_mods with the value ["gradualizer_prelude"]]. I also expect rebar to no crash but exit normally.

ferd commented 5 years ago

The configuration format is {dialyzer, [{exclude_mods, [gradualizer_prelude]}]}, and not {dialyzer, [exclude_mods, ["gradualizer_prelude"]]} as you entered it.

Note the tuples that act as a key/value pair. Changing the configuration to have the proper format should work.

josefs commented 5 years ago

Yes indeed. It would be helpful though if rebar gave a more informative error message.

ferd commented 5 years ago

Agreed. I think that's a general improvement that's a bit harder to drive as one single issue -- each provider (command) does its own handling. I'll close this issue, but we're welcoming of any contributions that can make such error handling clearer. Let me know if there's anything else that can be done in this issue and I'll reopen it.