Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash in pass beam_ssa_opt, sub pass ssa_opt_private_append (2) #6848

Closed
bjorng opened this issue Feb 11, 2023 · 0 comments · Fixed by #6855
Closed

Compiler crash in pass beam_ssa_opt, sub pass ssa_opt_private_append (2) #6848

bjorng opened this issue Feb 11, 2023 · 0 comments · Fixed by #6855
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@bjorng
Copy link
Contributor

bjorng commented Feb 11, 2023

Describe the bug
The compiler crashes with the following output:

Sub pass ssa_opt_private_append
beam_ssa_private_append_crash2.erl: internal error in pass beam_ssa_opt:
exception error: no case clause matching {{bif,'not'},[{b_var,1}],self}
  in function  beam_ssa_private_append:track_value_in_fun/6 (beam_ssa_private_append.erl, line 192)
  in call from beam_ssa_private_append:private_append/3 (beam_ssa_private_append.erl, line 71)
  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)
  in call from beam_ssa_opt:module/2 (beam_ssa_opt.erl, line 71)
  in call from compile:'-select_passes/2-anonymous-0-'/3 (compile.erl, line 683)
  in call from compile:fold_comp/4 (compile.erl, line 410)
  in call from compile:internal_comp/5 (compile.erl, line 394)

To Reproduce
Compile the following module:

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

f(A) ->
    <<(case ok of
           A ->
               not is_alive();
           _  ->
               <<>>
       end)/bitstring>>.

Expected behavior
Compilation should succeed.

Affected versions
The current master branch.

Additional context
Same sub pass as #6847, but the crash is in another function.

@bjorng bjorng added team:VM Assigned to OTP team VM bug Issue is reported as a bug labels Feb 11, 2023
@bjorng bjorng self-assigned this Feb 11, 2023
frej added a commit to frej/otp that referenced this issue Feb 13, 2023
The private-append optimization worked on the assumption that the
`private_append` version of `bs_create_bin` checked that the type of
the first argument was a bitstring. As it doesn't, the compiler
shouldn't do the optimization when it cannot guarantee that the type
is and only is a bitstring.

Fixes: erlang#6851
Fixes: erlang#6848
frej added a commit to frej/otp that referenced this issue Feb 14, 2023
The private-append optimization worked on the assumption that the
`private_append` version of `bs_create_bin` checked that the type of
the first argument was a bitstring. As it doesn't, the compiler
shouldn't do the optimization when it cannot guarantee that the type
is and only is a bitstring.

Fixes erlang#6851
Fixes erlang#6848
@bjorng bjorng linked a pull request Feb 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant