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 #7147

Closed
RobinMorisset opened this issue Apr 22, 2023 · 3 comments · Fixed by #7163
Closed

[erlc] internal error in pass beam_validator_strong #7147

RobinMorisset opened this issue Apr 22, 2023 · 3 comments · Fixed by #7163
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@RobinMorisset
Copy link
Contributor

Describe the bug
Running erlc on the following:

f(Y, X) ->
    fun(X) ->
        <<Y:(abs(ceil(-1.0 = X)))/float, (binary_to_integer(ok))>>,
        ceil(X) band Y
    end.

results in the following error message:

Function: '-f/2-fun-0-'/2
/home/rmorisset/minimized/validator.erl: internal error in pass beam_validator_strong:
exception error: no match of right hand side value false
  in function  beam_validator:unpack_typed_arg/2 (beam_validator.erl, line 2833)
  in call from beam_validator:'-vi/2-lc$^20/1-9-'/2 (beam_validator.erl, line 754)
  in call from beam_validator:vi/2 (beam_validator.erl, line 754)
  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 1682)

Affected versions
master

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Apr 22, 2023
@rickard-green rickard-green added the team:VM Assigned to OTP team VM label Apr 24, 2023
@bjorng bjorng self-assigned this Apr 24, 2023
@RobinMorisset
Copy link
Contributor Author

commit 039c5de (from #7157) changes the error message to:

validator:1: function '-f/2-fun-0-'/2+14:
  Internal consistency check failed - please report this bug.
  Instruction: {gc_bif,'band',
                       {f,0},
                       0,
                       [{tr,{y,0},{t_integer,any}},{integer,-1}],
                       {x,0}}
  Error:       {bad_typed_register,{t_float,any},{t_integer,any}}:

@jhogberg
Copy link
Contributor

039c5de is a drive-by fix for better error reporting in this case, the crash is the same.

@bjorng has a fix in the works :-)

bjorng added a commit to bjorng/otp that referenced this issue Apr 25, 2023
Issue erlang#7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands
that the compiler would do to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation would not be
updated.

The second one is `beam_validator`, that assumed that if the binary
construction `<<F/float>>` succeeded, then `F` must be a float. That
is not correct, because `F` could also be an integer.

Closes erlang#7147
bjorng added a commit to bjorng/otp that referenced this issue Apr 25, 2023
Issue erlang#7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands
that the compiler would do to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation would not be
updated.

The second one is `beam_validator`, that assumed that if the binary
construction `<<F/float>>` succeeded, then `F` must be a float. That
is not correct, because `F` could also be an integer.

Closes erlang#7147
bjorng added a commit to bjorng/otp that referenced this issue Apr 25, 2023
Issue erlang#7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands,
which the compiler does to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation were not
updated.

The second one is in `beam_validator`, which assumed that if the
binary construction `<<F/float>>` succeeded, then `F` must be a
float. That is not correct, because `F` could also be an integer.

Closes erlang#7147
bjorng added a commit to bjorng/otp that referenced this issue Apr 25, 2023
Issue erlang#7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands,
which the compiler does to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation were not
updated.

The second one is in `beam_validator`, which assumed that if the
binary construction `<<F/float>>` succeeded, then `F` must be a
float. That is not correct, because `F` could also be an integer.

Closes erlang#7147
@bjorng
Copy link
Contributor

bjorng commented Apr 25, 2023

The linked pull request fixes the bugs for OTP 26. The fix will also be released in a patch for OTP 25.

bjorng added a commit to bjorng/otp that referenced this issue Apr 25, 2023
Issue erlang#7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands,
that the compiler does to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation was not
updated.

The second one is in `beam_validator`, which assumed that if the
binary construction `<<F/float>>` succeeded, then `F` must be a
float. That is not correct, because `F` could also be an integer.

Closes erlang#7147
bjorng added a commit that referenced this issue Apr 26, 2023
bjorng added a commit that referenced this issue May 2, 2023
Issue #7147 uncovered two bugs in the compiler.

The first one is in the swapping of operands for commutative operands,
that the compiler does to simplify for the JIT. When the operands
were swapped, types for the operands in the annotation were not
updated.

The second one is in `beam_validator`, which assumed that if the
binary construction `<<F/float>>` succeeded, then `F` must be a
float. That is not correct, because `F` could also be an integer.

Closes #7147
bjorng added a commit that referenced this issue May 2, 2023
…o maint

* bjorn/compiler/beam_validator/25/GH-7147/OTP-18565:
  Fix two type-related bugs
sverker pushed a commit that referenced this issue May 5, 2023
…o maint-25

* bjorn/compiler/beam_validator/25/GH-7147/OTP-18565:
  Fix two type-related bugs
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.

4 participants