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] Crash in beam_ssa_opt with -0.0 #8097

Open
RobinMorisset opened this issue Feb 8, 2024 · 3 comments
Open

[erlc] Crash in beam_ssa_opt with -0.0 #8097

RobinMorisset opened this issue Feb 8, 2024 · 3 comments
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:

-feature(maybe_expr, enable).
-module(test258136).
-export([f/0]).

f() ->
    <<
        (ok)
     || _ := {_V1} <- ok,
        (maybe
            {} ?= _V1
        else
            -0.0 ->
                [];
            0.0 ->
                []
        end)
    >>.

crashes with the following message:

Function: '-f/0-lbc$^0/2-0-'/2
Sub pass ssa_opt_type_start
/home/rmorisset/minimized/test258136.erl: internal error in pass beam_ssa_opt:
exception error: no case clause matching {{1,{t_float,{-0.0,-0.0}}},{1,{t_float,{0.0,0.0}}}}
  in function  beam_types:join/2 (beam_types.erl, line 256)
  in call from beam_ssa_type:join_types_1/3 (beam_ssa_type.erl, line 2896)
  in call from beam_ssa_type:update_successor/3 (beam_ssa_type.erl, line 2077)
  in call from beam_ssa_type:update_switch/8 (beam_ssa_type.erl, line 2036)
  in call from beam_ssa_type:update_successors/5 (beam_ssa_type.erl, line 2001)
  in call from beam_ssa_type:sig_bs/8 (beam_ssa_type.erl, line 258)
  in call from beam_ssa_type:sig_function_1/4 (beam_ssa_type.erl, line 221)
  in call from beam_ssa_type:do_sig_function/4 (beam_ssa_type.erl, line 169)

Affected versions

@RobinMorisset RobinMorisset added the bug Issue is reported as a bug label Feb 8, 2024
@RobinMorisset
Copy link
Contributor Author

Another example with a fairly similar error message:

-module(test386949).
-export([a/0, b/0, c/0]).

f(_V1) when ((+_V1) >= ok) ->
    <<(ok) || _ <- ok>>.

a() ->
    f(ok).

b() ->
    f(1.0).

c() ->
    f(2147483647).

crashes erlc with

Sub pass ssa_opt_type_continue
Function: '-f/1-lbc$^0/2-0-'/2
/home/rmorisset/minimized/test386949.erl: internal error in pass beam_ssa_opt:
exception error: no function clause matching beam_types:join([]) 
  in function  beam_ssa_type:join_arg_types/3 (beam_ssa_type.erl, line 447)
  in call from beam_ssa_type:opt_continue/4 (beam_ssa_type.erl, line 430)
  in call from beam_ssa_opt:ssa_opt_type_continue/1 (beam_ssa_opt.erl, line 439)
  in call from compile:run_sub_passes_1/3 (compile.erl, line 1184)
  in call from beam_ssa_opt:phase/4 (beam_ssa_opt.erl, line 118)
  in call from beam_ssa_opt:fixpoint/6 (beam_ssa_opt.erl, line 101)
  in call from beam_ssa_opt:run_phases/3 (beam_ssa_opt.erl, line 87)

This one does not rely on 0.0/-0.0, so it may have been a red herring. I'm also wondering whether it might be yet another instance of #7342.

@bjorng bjorng added the team:VM Assigned to OTP team VM label Feb 8, 2024
@jhogberg jhogberg self-assigned this Feb 8, 2024
@jhogberg
Copy link
Contributor

jhogberg commented Feb 8, 2024

Thanks, these are two separate issues. I've fixed the first in #8101 and will look into the second now :)

@jhogberg
Copy link
Contributor

jhogberg commented Feb 8, 2024

I've pushed a commit that fixes the second one now too, on the same branch because I'm feeling lazy. :D

Nevermind, it traded one bug for another -- to be continued.

bjorng added a commit that referenced this issue Feb 9, 2024
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

No branches or pull requests

3 participants