aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-04-07 13:18:24 +0200
committerBjörn Gustavsson <[email protected]>2010-04-07 13:25:02 +0200
commitfd9bb9fb7323ead417fff0cbb7a077b342446a77 (patch)
tree6841f2c97ce249bc44ec7d4485cd533ae7690df6 /erts
parent6fd69d6ca5cea3aae4afce7544ba6b729221885c (diff)
downloadotp-fd9bb9fb7323ead417fff0cbb7a077b342446a77.tar.gz
otp-fd9bb9fb7323ead417fff0cbb7a077b342446a77.tar.bz2
otp-fd9bb9fb7323ead417fff0cbb7a077b342446a77.zip
erts: Fix loading of modules with invalid floating point arithmetic
The following program is supposed to cause an exception at run-time: foo() -> Sum1 = Sum2 = N = 2, pSum - (Sum1*(Sum2/N)). but the loader fails to load because it contains the following instruction: fconv {atom,pSum} {fr,2} Fix the loader so that it can handle fconv instructions where the first operand is a non-numeric literal. Reported-by: Torbjörn Törnkvist
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/ops.tab2
-rw-r--r--erts/emulator/test/beam_SUITE.erl25
2 files changed, 25 insertions, 2 deletions
diff --git a/erts/emulator/beam/ops.tab b/erts/emulator/beam/ops.tab
index 231ea34fd5..9e8ac74f40 100644
--- a/erts/emulator/beam/ops.tab
+++ b/erts/emulator/beam/ops.tab
@@ -1304,7 +1304,7 @@ fmul p FR1 FR2 FR3 => i_fmul FR1 FR2 FR3
fdiv p FR1 FR2 FR3 => i_fdiv FR1 FR2 FR3
fnegate p FR1 FR2 => i_fnegate FR1 FR2
-fconv Int=iq Dst=l => move Int x | fconv x Dst
+fconv Arg=iqan Dst=l => move Arg x | fconv x Dst
fmove q l
fmove d l
diff --git a/erts/emulator/test/beam_SUITE.erl b/erts/emulator/test/beam_SUITE.erl
index cc1626630b..d712691871 100644
--- a/erts/emulator/test/beam_SUITE.erl
+++ b/erts/emulator/test/beam_SUITE.erl
@@ -20,7 +20,7 @@
-module(beam_SUITE).
-export([all/1, packed_registers/1, apply_last/1, apply_last_bif/1,
- buildo_mucho/1, heap_sizes/1, big_lists/1]).
+ buildo_mucho/1, heap_sizes/1, big_lists/1, fconv/1]).
-export([applied/2]).
@@ -279,3 +279,26 @@ b() ->
_} ->
ok
end.
+
+fconv(Config) when is_list(Config) ->
+ ?line do_fconv(atom),
+ ?line do_fconv(nil),
+ ?line do_fconv(tuple_literal),
+ ?line 3.0 = do_fconv(1.0, 2.0),
+ ok.
+
+do_fconv(Type) ->
+ try
+ do_fconv(Type, 1.0),
+ test_server:fail()
+ catch
+ error:badarith ->
+ ok
+ end.
+
+do_fconv(atom, Float) when is_float(Float) ->
+ Float + a;
+do_fconv(nil, Float) when is_float(Float) ->
+ Float + [];
+do_fconv(tuple_literal, Float) when is_float(Float) ->
+ Float + {a,b}.