Skip to content

internal error in pass beam_ssa_opt in erlc if trying to index tuples above system limits in lists:keyfind #11413

Description

@lmaltsis

Describe the bug

$ erlc /tmp/bug.erl
Function: f/0
Sub pass ssa_opt_type_start
/tmp/bug.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:1160)
  in call from beam_types:glb/2 (beam_types.erl:1099)
  in call from beam_ssa_type:simplify/3 (beam_ssa_type.erl:1262)
  in call from beam_ssa_type:simplify/6 (beam_ssa_type.erl:979)
  in call from beam_ssa_type:sig_is/7 (beam_ssa_type.erl:329)
  in call from beam_ssa_type:sig_bs/8 (beam_ssa_type.erl:271)
  in call from beam_ssa_type:sig_function_1/4 (beam_ssa_type.erl:236)
  in call from beam_ssa_type:do_sig_function/4 (beam_ssa_type.erl:180)

To Reproduce
https://godbolt.org/z/o5rahrd4s

-module(program).
-export([f/0]).

f() ->
    {_, _} = lists:keyfind(0, 16777216, lists:zip([], []) ).

using 16777215 instead compiles fine, so the boundry is exactly at 2^24-1

Expected behavior
This is theoretically invalid code according to https://www.erlang.org/doc/system/system_limits.html

Other code of a similar nature compiles and then crashes at runtime, e.g.

-module(f).
-export([f/1]).

f(T) -> element(16777216, T).

Affected versions
trunk 756ba35
all stable ones I could test on compiler explorer, e.g. https://godbolt.org/z/o5rahrd4s

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions