From fd9bb9fb7323ead417fff0cbb7a077b342446a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 7 Apr 2010 13:18:24 +0200 Subject: erts: Fix loading of modules with invalid floating point arithmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- erts/emulator/test/beam_SUITE.erl | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'erts/emulator/test/beam_SUITE.erl') 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}. -- cgit v1.2.3