erlef / rebar3_hex

Rebar3 Hex library
Apache License 2.0
101 stars 49 forks source link

Crash while running `rebar3 hex cut` #316

Closed saleyn closed 1 year ago

saleyn commented 1 year ago

Description

When running rebar3 hex cut in the source of the erlcron repository, I get a rebar3.crashdump.

Error: function_clause
[{rebar3_hex_cut,cut,
  [{state_t,"/home/serge/projects/erl-libs/erlcron",
    {dict,28,16,16,8,80,48,
     {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
     {{[],
       [[{deps,default}],
  ...
    0,undefined,"/home/serge/projects/erl-libs/erlcron",
    "/home/serge/projects/erl-libs/erlcron/_build/default/lib/erlcron",
    "/home/serge/projects/erl-libs/erlcron/_build/default/lib/erlcron/ebin",
    undefined,false,false,false,undefined,false},
   #{task => undefined}],
  [{file,
    "/home/serge/projects/erl-libs/erlcron/_build/default/plugins/rebar3_hex/src/rebar3_hex_cut.erl"},
   {line,141}]},
 {lists,foreach_1,2,[{file,"lists.erl"},{line,1442}]},
 {rebar3_hex_cut,handle_task,1,
  [{file,
    "/home/serge/projects/erl-libs/erlcron/_build/default/plugins/rebar3_hex/src/rebar3_hex_cut.erl"},
   {line,122}]},
 {rebar_core,do,2,
  [{file,"/home/serge/projects/erl-libs/rebar3/apps/rebar/src/rebar_core.erl"},
   {line,155}]},
 {rebar_prv_do,do_task,5,
  [{file,
    "/home/serge/projects/erl-libs/rebar3/apps/rebar/src/rebar_prv_do.erl"},
   {line,87}]},
 {rebar_core,do,2,
  [{file,"/home/serge/projects/erl-libs/rebar3/apps/rebar/src/rebar_core.erl"},
   {line,155}]},
 {rebar3,run_aux,2,
  [{file,"/home/serge/projects/erl-libs/rebar3/apps/rebar/src/rebar3.erl"},
   {line,193}]},
 {rebar3,main,1,
  [{file,"/home/serge/projects/erl-libs/rebar3/apps/rebar/src/rebar3.erl"},
   {line,66}]}]

Here's the rebar.config:

$ cat rebar.config 
%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
%% Dependencies ================================================================
{deps, []}.

%% Rebar Plugins ===============================================================
{plugins, [rebar3_hex, rebar3_ex_doc]}.

%% Compiler Options ============================================================
{erl_opts, [debug_info, warnings_as_errors]}.

%% Doc provider  ===============================================================
{ex_doc, [
   {source_url, <<"https://github.com/erlware/erlcron">>},
   {extras, [<<"README.md">>, <<"LICENSE">>]},
   {main, <<"readme">>}
]}.

{hex, [{doc, ex_doc}]}.

%% EUnit =======================================================================
{eunit_opts, [%verbose,
              %{report, {eunit_surefire, [{dir, "."}]}}]}.
             no_tty]}.

{cover_enabled, true}.
{cover_print_enabled, true}.

Environment

$ rebar3 report "hex cut"
Rebar3 report
 version 3.20.0
 generated at 2023-01-24T16:53:39+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: hex
Entered as:
  hex cut
-----------------
Operating System: x86_64-pc-linux-gnu
ERTS: Erlang/OTP 25 [erts-13.0.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]
Root Directory: /opt/sw/erlang/v25.0.4/lib/erlang
Library directory: /opt/sw/erlang/v25.0.4/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.12.2
certifi: 2.10.0
cf: 0.3.1
common_test: 1.23
compiler: 8.2
crypto: 5.1.1
cth_readable: 1.5.1
dialyzer: 5.0.1
edoc: 1.2
erlware_commons: 1.5.0
eunit: 2.7.1
eunit_formatters: 0.5.0
getopt: 1.0.1
inets: 8.0
kernel: 8.4.2
providers: 1.9.0
public_key: 1.13
relx: 4.7.0
sasl: 4.2
snmp: 5.13
ssl_verify_fun: 1.1.6
stdlib: 4.0.1
syntax_tools: 3.0
tools: 3.5.3

-----------------
Escript path: /opt/bin/rebar3
Providers:
  app_discovery as build clean compile compile cover ct cut deps dialyzer do docs edoc escriptize eunit ex_doc get-deps help install install_deps key list lock new organization owner path pkgs publish release relup repo report repos retire revert search shell state tar tree unlock update upgrade upgrade upgrade user vendor version xref
saleyn commented 1 year ago

I seem to be able to bypass the crash by passing the -i patch option to hex cut, but as I understand it, the -i option is documented as optional, so I don't expect to see a crash if the option is not given.

starbelly commented 1 year ago

Closed via #317

starbelly commented 1 year ago

I closed this an error. It seems you have pointed out there still might seem to be a place to crash. I'll look further in a bit.

starbelly commented 1 year ago

Hey @saleyn , I can't seem to replicate this (I cloned erlcron repo and ran cut), but I did find a bug if you choose other as the version type to go with when incrementing. Maybe you went down that path? Doesn't seem like it per your issue (i.e., you just ran cut and it blew up).

saleyn commented 1 year ago

Presently I cannot reproduce it either. Maybe it's because my fix to rebar3_hex was merged or some other change was made to the head of the repo?

starbelly commented 1 year ago

Presently I cannot reproduce it either. Maybe it's because my fix to rebar3_hex was merged or some other change was made to the head of the repo?

That's possible. It's also possible you were on an older version of rebar3_hex at the time. I'm glad it's all resolved, at least for now! 👍