diff options
author | Björn Gustavsson <[email protected]> | 2016-05-17 07:09:59 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-05-23 08:39:32 +0200 |
commit | 121cc9ba61e44e9c47d831d837dfb0f0b2d81990 (patch) | |
tree | c2faba2d3d5a0dff283105f1c4c3dd4e7977c82f /lib/compiler/priv | |
parent | 0f222d55ce46358aa7891ea482655937daaf8b52 (diff) | |
download | otp-121cc9ba61e44e9c47d831d837dfb0f0b2d81990.tar.gz otp-121cc9ba61e44e9c47d831d837dfb0f0b2d81990.tar.bz2 otp-121cc9ba61e44e9c47d831d837dfb0f0b2d81990.zip |
beam_type: Eliminate crash
The following code:
simple() ->
case try 0 after [] end of
0 -> college;
1 -> 0
end.
would crash the compiler like this:
crash reason: {case_clause,
{'EXIT',
{function_clause,
[{beam_type,simplify_select_val_int,
[{select,select_val,
{x,0},
{f,7},
[{integer,1},{f,9},{integer,0},{f,8}]},
0],
[{file,"beam_type.erl"},{line,169}]},
{beam_type,simplify_basic_1,3,
[{file,"beam_type.erl"},{line,155}]},
{beam_type,opt,3,[{file,"beam_type.erl"},{line,57}]},
{beam_type,function,1,[{file,"beam_type.erl"},{line,36}]},
{beam_type,'-module/2-lc$^0/1-0-',1,
[{file,"beam_type.erl"},{line,30}]},
{beam_type,module,2,[{file,"beam_type.erl"},{line,30}]},
{compile,'-select_passes/2-anonymous-2-',2,
[{file,"compile.erl"},{line,521}]},
{compile,'-internal_comp/4-anonymous-1-',2,
[{file,"compile.erl"},{line,306}]}]}}}
The root cause is that the type representation is not well-defined.
Integers could be represented in three different ways:
integer
{integer,{1,10}}
{integer,0}
However, only the first two forms were handled.
To avoid similar problems in the future:
* Make the type representation stricter. Make sure that integers are
only represented as 'integer' or {integer,{Min,Max}}.
* Call verify_type/1 whenever a new type is added (not only when
merging types) to ensure that only the supported types are added
to the type database).
(ERL-150)
Diffstat (limited to 'lib/compiler/priv')
0 files changed, 0 insertions, 0 deletions