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 consistency error (suspected to be about CSE of division) #6163

Closed
RobinMorisset opened this issue Jul 22, 2022 · 2 comments · Fixed by #6168
Closed

Erlc internal consistency error (suspected to be about CSE of division) #6163

RobinMorisset opened this issue Jul 22, 2022 · 2 comments · Fixed by #6168
Assignees
Labels
bug Issue is reported as a bug in progress team:VM Assigned to OTP team VM

Comments

@RobinMorisset
Copy link
Contributor

On the following code:

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

f1(_, _) ->
    0.

f2(V) ->
    f1(
        is_tuple(V) orelse (1 / V),
        (1 / V) andalso true
    ).

erlc crashes with the following error message:

cse_div:1: function f2/1+15:
Internal consistency check failed - please report this bug.
Instruction: {bif,fdiv,{f,0},[{fr,0},{fr,1}],{fr,0}}
Error: {uninitialized_reg,{fr,0}}:

The bug still reproduces if I replace both instances of 1 / V by 0 / V, but not if I only replace one, so I suspect that the problem is related to Common Subexpression Elimination of the division.

The call to is_tuple(V) can be replaced by is_list(V) and the bug still reproduces, but the crash disappears if it is removed altogether.

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Jul 22, 2022
@bjorng bjorng added the team:VM Assigned to OTP team VM label Jul 25, 2022
@bjorng bjorng self-assigned this Jul 25, 2022
bjorng added a commit to bjorng/otp that referenced this issue Jul 25, 2022
@bjorng bjorng linked a pull request Jul 25, 2022 that will close this issue
@bjorng
Copy link
Contributor

bjorng commented Jul 25, 2022

Thanks for the bug report.

CSE is a reasonable hypothesis, but that is not the problem. The problem is in the pass that rewrites general arithmetic instructions to specialised floating point instructions.

The linked pull request resolves the problem. It will be included in OTP 25.1 and also in the next patch for OTP 24.

@RobinMorisset
Copy link
Contributor Author

Thank you for this quick answer and investigation!

bjorng added a commit to bjorng/otp that referenced this issue Jul 27, 2022
…182' into maint

* bjorn/compiler/fix-unsafe-float-op/erlangGH-6163/OTP-18182:
  Fix internal consistency error
@bjorng bjorng closed this as completed in c8e684e Jul 27, 2022
lthor pushed a commit that referenced this issue Aug 18, 2022
…nto maint-24

* bjorn/compiler/fix-unsafe-float-op/GH-6163/OTP-18182:
  Fix internal consistency error
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 in progress team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants