erlang/otp

Compiler crash in pass beam_ssa_opt, sub pass ssa_opt_private_append

bjorng opened this issue · 3 comments

Describe the bug
The compiler crashes like this when compiling the module shown below:

Sub pass ssa_opt_private_append
beam_ssa_private_append_crash.erl: internal error in pass beam_ssa_opt:
exception error: no function clause matching beam_ssa_private_append:patch_literal_term([],[self],5) 
  in function  beam_ssa_private_append:patch_appends_ret/3 (beam_ssa_private_append.erl, line 462)
  in call from beam_ssa_private_append:patch_appends_f/5 (beam_ssa_private_append.erl, line 416)
  in call from beam_ssa_private_append:'-patch_appends/3-anonymous-2-'/3 (beam_ssa_private_append.erl, line 390)
  in call from maps:fold_1/4 (maps.erl, line 416)
  in call from beam_ssa_private_append:private_append/3 (beam_ssa_private_append.erl, line 72)
  in call from compile:run_sub_passes_1/3 (compile.erl, line 424)
  in call from beam_ssa_opt:run_phases/3 (beam_ssa_opt.erl, line 75)

To Reproduce
Compile the following module:

-module(beam_ssa_private_append_crash).
-compile([export_all]).

foo() ->
    <<(bar(ok))/binary>>.

bar(#{}) ->
    [];
bar(_) ->
    <<>>.

Expected behavior
The compilation should succeed.

Affected versions
The current master branch.

@frej,

As a bonus, here is how the currently not covered line 548 in beam_ssa_private_append can be covered:

cover_beam_ssa_private_append_line_548() ->
    <<(try
           <<>> = ok
       catch
           throw:#{} ->
               <<>>;
           _  ->
               ok
       end)/binary>>.
frej commented

@bjorng, is it ok if I look at this and #6848 on Monday?

@frej Yes, of course. It's not urgent. Sorry for not making that clear. Bug fixes for minor bugs will be included in the second release candidate, not the the first.