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

beam_ssa_type: Fix bugs relating to subtraction in type inference #7489

Conversation

jhogberg
Copy link
Contributor

Fixes #7488

@jhogberg jhogberg added team:VM Assigned to OTP team VM fix testing currently being tested, tag is used by OTP internal CI labels Jul 11, 2023
@jhogberg jhogberg self-assigned this Jul 11, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2023

CT Test Results

       2 files     296 suites   12m 13s ⏱️
   778 tests    776 ✔️ 2 💤 0
4 921 runs  4 919 ✔️ 2 💤 0

Results for commit 3379f7c.

♻️ 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 added this to the OTP-26.0.3 milestone Jul 11, 2023
@jhogberg jhogberg changed the base branch from master to maint-26 July 11, 2023 09:21
@RobinMorisset
Copy link
Contributor

RobinMorisset commented Jul 13, 2023

erlfuzz found two crashes that only reproduce with this PR:

f(_V0) when is_boolean(_V0), is_binary(_V0), _V0 andalso _V0 ->
    ok.

causes the following error:

Function: f/1
Sub pass ssa_opt_type_start
/home/rmorisset/minimized/test214716.erl: internal error in pass beam_ssa_opt:
exception error: no case clause matching {none,none}
  in function  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 257)
  in call from beam_ssa_type:sig_function_1/4 (beam_ssa_type.erl, line 220)
  in call from beam_ssa_type:do_sig_function/4 (beam_ssa_type.erl, line 168)
  in call from beam_ssa_type:sig_function/4 (beam_ssa_type.erl, line 159)
  in call from beam_ssa_type:signatures_1/3 (beam_ssa_type.erl, line 147)
  in call from beam_ssa_type:signatures/2 (beam_ssa_type.erl, line 141)
  in call from beam_ssa_type:opt_start/2 (beam_ssa_type.erl, line 80)

And

f(_V0) ->
    try
        _V0 = ok
    catch
        _ ->
            <<
                0
             || _V0 := _ <- ok,
                (try ok of
                    _ when _V0, (_V0 andalso _V0) orelse trunc(ok) ->
                        ok
                catch
                    _ ->
                        ok
                end)
            >>
    end.

causes the following error:

Function: '-f/1-lbc$^0/2-0-'/2
Sub pass ssa_opt_type_continue
Function: '-f/1-lbc$^0/2-0-'/2
/home/rmorisset/minimized/test408856.erl: internal error in pass beam_ssa_opt:
exception error: no match of right hand side value none
  in function  beam_ssa_type:concrete_type/2 (beam_ssa_type.erl, line 2449)
  in call from beam_ssa_type:subtract_types/2 (beam_ssa_type.erl, line 2898)
  in call from beam_ssa_type:infer_types_br_1/3 (beam_ssa_type.erl, line 2517)
  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:opt_bs/8 (beam_ssa_type.erl, line 529)
  in call from beam_ssa_type:do_opt_function/6 (beam_ssa_type.erl, line 501)
  in call from beam_ssa_type:opt_function/6 (beam_ssa_type.erl, line 474)

I don't know whether these two crashes are symptoms of a single bug or separate issues.

@jhogberg
Copy link
Contributor Author

Thanks, that looks like ye olde #6599/#7342 again :(

@RobinMorisset
Copy link
Contributor

Ah, I had hope it was something new since it needs the PR to trigger. But I guess it might have just revealed a pre-existing bug :-/.

@jhogberg jhogberg force-pushed the john/compiler/fix-missing-type-subtraction/GH-7488/OTP-18678 branch 2 times, most recently from 7c7bcd2 to 5610c3e Compare July 14, 2023 07:33
@jhogberg
Copy link
Contributor Author

I take that back, it was a bug in this PR. Thanks! :D

@jhogberg jhogberg force-pushed the john/compiler/fix-missing-type-subtraction/GH-7488/OTP-18678 branch from 5610c3e to 492cca7 Compare July 14, 2023 07:34
@RobinMorisset
Copy link
Contributor

Thanks for the fix. I checked and it solved all the crashing testcases found by erlfuzz.
Can you add the first test case above to the test suite? So that these lines in the compiler are covered and if anyone breaks them the regression will be caught.

@jhogberg jhogberg force-pushed the john/compiler/fix-missing-type-subtraction/GH-7488/OTP-18678 branch from 492cca7 to 3379f7c Compare July 17, 2023 10:10
@proxyles proxyles merged commit fe0571e into erlang:maint-26 Sep 20, 2023
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.

Erlang fails to compile valid code on tuple element guards
3 participants