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: Fix some vestigial +0.0/-0.0 issues #7902

Merged

Conversation

jhogberg
Copy link
Contributor

Fixes #7901

@jhogberg jhogberg added team:VM Assigned to OTP team VM fix labels Nov 23, 2023
@jhogberg jhogberg requested a review from bjorng November 23, 2023 17:30
@jhogberg jhogberg self-assigned this Nov 23, 2023
Copy link
Contributor

github-actions bot commented Nov 23, 2023

CT Test Results

       2 files     323 suites   8m 48s ⏱️
   780 tests    778 ✔️ 2 💤 0
5 326 runs  5 324 ✔️ 2 💤 0

Results for commit 34ef50c.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@jhogberg jhogberg force-pushed the john/compiler/float-confusion/GH-7901 branch from cd8df67 to 78d76a3 Compare November 23, 2023 22:52
lib/compiler/src/beam_types.erl Outdated Show resolved Hide resolved
lib/compiler/src/beam_types.erl Outdated Show resolved Hide resolved
@RobinMorisset
Copy link
Contributor

Thanks for this quick fix.
Some variants of the original bug remain, e.g.:

-export([f2/0, start/0]).

f2() ->
    [ok || _ := _ <- ok, f3(catch f3(ok, -1), -0.0)].

f3(_, 18446744073709551615) ->
    ok.

start() ->
    f3(ok, ok).

Still crashes with

test98296:1: function '-f2/0-lc$^0/1-0-'/1+17:
  Internal consistency check failed - please report this bug.
  Instruction: {call_last,2,{f,9},1}
  Error:       {bad_arg_type,{x,1},
                             {t_float,{-0.0,-0.0}},
                             {t_union,{t_atom,[ok]},
                                      none,
                                      {t_number,{-1,0}},
                                      none,none}}:

@jhogberg
Copy link
Contributor Author

Thanks, I'll get right on it :)

@RobinMorisset
Copy link
Contributor

This PR also seems to have introduced a new bug:

-export([f4/1]).

f4(_V1) ->
    -0.0 = abs(_V1).

Crashes erlc with

Function: f4/1
Sub pass ssa_opt_type_start
/home/rmorisset/minimized/test98057.erl: internal error in pass beam_ssa_opt:
exception error: no match of right hand side value false
  in function  beam_types:glb_ranges/2 (beam_types.erl, line 933)
  in call from beam_types:glb/2 (beam_types.erl, line 879)
  in call from beam_ssa_type:meet_types/2 (beam_ssa_type.erl, line 2896)
  in call from beam_ssa_type:infer_types_br_1/3 (beam_ssa_type.erl, line 2512)
  in call from beam_ssa_type:infer_types_br/4 (beam_ssa_type.erl, line 2477)
  in call from beam_ssa_type:update_successors/5 (beam_ssa_type.erl, line 1968)
  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)

but only with this PR.

@RobinMorisset
Copy link
Contributor

This PR also seems to have introduced a new bug:

Two other testcases with the same symptom:

-export([f7/1]).

f7(_V1) when -0.0 < floor(_V1 band 1) ->
    ok.

and

-export([f9/0]).

f9() ->
    -0.0 =
        case
            fun() ->
                ok
            end
        of
            _V2 when (_V2 > ok) ->
                2147483647.0;
            _ ->
                -2147483648
        end * 0.

@jhogberg
Copy link
Contributor Author

Thanks, I had introduced some inconsistencies in the lattice, I've pushed up a new version now :)

@jhogberg jhogberg force-pushed the john/compiler/float-confusion/GH-7901 branch from 78d76a3 to 653e6c6 Compare November 24, 2023 09:26
@RobinMorisset
Copy link
Contributor

erlfuzz has run for more than 1h with no bug found (it was finding one every 5 to 10mn before this latest fix), so it seems to be fixed for good, thanks!

@jhogberg jhogberg added the testing currently being tested, tag is used by OTP internal CI label Nov 28, 2023
@jhogberg jhogberg force-pushed the john/compiler/float-confusion/GH-7901 branch 2 times, most recently from 1697ed9 to 5624839 Compare November 29, 2023 13:44
@jhogberg jhogberg force-pushed the john/compiler/float-confusion/GH-7901 branch from 5624839 to 34ef50c Compare November 30, 2023 08:58
@jhogberg jhogberg merged commit a5064e9 into erlang:master Dec 6, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[erlc] Consistency check failure related to -0.0/+0.0: "bad_arg_type"
3 participants