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

[erlc] internal error in pass beam_validator_strong #6551

Closed
RobinMorisset opened this issue Dec 14, 2022 · 0 comments · Fixed by #6556
Closed

[erlc] internal error in pass beam_validator_strong #6551

RobinMorisset opened this issue Dec 14, 2022 · 0 comments · Fixed by #6556
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@RobinMorisset
Copy link
Contributor

On master:

f(X) ->
    case X of
        <<>> ->
            (true -- []);
        <<_>> ->
            X
    end /= X.

crashes erlc with the following error message:

Function: '-f1/0-fun-0-'/1
minimized/validator_get_tail_1.erl: internal error in pass beam_validator_strong:
exception error: no case clause matching {get_tail,2,1,{x,0}}
  in function  beam_validator:validate_bs_match/4 (beam_validator.erl, line 1716)
  in call from beam_validator:branch/4 (beam_validator.erl, line 2879)
  in call from beam_validator:validate_instrs/4 (beam_validator.erl, line 333)
  in call from beam_validator:validate_1/5 (beam_validator.erl, line 276)
  in call from beam_validator:validate_0/4 (beam_validator.erl, line 114)
  in call from beam_validator:validate/2 (beam_validator.erl, line 56)
  in call from compile:beam_validator_1/3 (compile.erl, line 1663)
  in call from compile:fold_comp/4 (compile.erl, line 408)

Some very similar testcases cause the same error message:

f(X) ->
    {X,
        case X of
            0 ->
                0;
            <<_>> ->
                X
        end}.

and

f1(X) ->
    f2(
        (case X of
            a ->
                X;
            <<_>> ->
                X
        end),
        X
    ).

f2(_, false) ->
    ok.
@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Dec 14, 2022
@bjorng bjorng added the team:VM Assigned to OTP team VM label Dec 14, 2022
@bjorng bjorng self-assigned this Dec 14, 2022
bjorng added a commit to bjorng/otp that referenced this issue Dec 15, 2022
`beam_validator` and `beam_disasm` assumed that there could only
be one `get_tail` command in a `bs_match` instruction. That assumption
is wrong. In rare circumstances, there can be more than one.

Closes erlang#6551
bjorng added a commit to bjorng/otp that referenced this issue Dec 15, 2022
* bjorn/compiler/double-get_tail/erlangGH-6551:
  Eliminate internal error in beam_validator
bjorng added a commit that referenced this issue Dec 16, 2022
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.

2 participants