aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-04-15 12:55:01 +0200
committerBjörn Gustavsson <[email protected]>2019-04-15 12:55:01 +0200
commit113f6917a343a5db98e4771598f1a190779ca2e8 (patch)
tree5c361cd2a067386b3ba57f2c1411320f1f9f92c5 /erts
parent7ed0636c69eafed0f30ac4bd7ae2acddeb5010d2 (diff)
parent256824fc2e441c549a39197bdae9ba8721709a8b (diff)
downloadotp-113f6917a343a5db98e4771598f1a190779ca2e8.tar.gz
otp-113f6917a343a5db98e4771598f1a190779ca2e8.tar.bz2
otp-113f6917a343a5db98e4771598f1a190779ca2e8.zip
Merge branch 'bjorn/cuddle-with-tests'
* bjorn/cuddle-with-tests: crash dump: Fix printing of "OldBinVHeap unused" crash dump: Include correct IP for a garbing process fun_SUITE: Make refc/1 test more reliable Remove redundant rule from Emakefile Turn off more optimizations for no_opt modules test_server_node: Bump compiler compatibility version to OTP 20 erts_test_utils: Bump compiler compatibility version to OTP 20 distribution_SUITE: Remove irrelevant test atom_roundtrip_r16b bs_construct_SUITE: Rename bs_add_overflow/1 to bs_append_overflow/1 bs_construct_SUITE: Remove troublesome test huge_binary/1 bs_construct_SUITE: Remove incorrect purpose line
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/break.c8
-rw-r--r--erts/emulator/beam/bs_instrs.tab2
-rw-r--r--erts/emulator/beam/instrs.tab2
-rw-r--r--erts/emulator/beam/macros.tab15
-rw-r--r--erts/emulator/test/Makefile8
-rw-r--r--erts/emulator/test/bs_construct_SUITE.erl86
-rw-r--r--erts/emulator/test/bs_match_int_SUITE.erl71
-rw-r--r--erts/emulator/test/distribution_SUITE.erl20
-rw-r--r--erts/emulator/test/erts_test_utils.erl2
-rw-r--r--erts/emulator/test/fun_SUITE.erl2
10 files changed, 88 insertions, 128 deletions
diff --git a/erts/emulator/beam/break.c b/erts/emulator/beam/break.c
index 06d8c7cda8..80e871aaf6 100644
--- a/erts/emulator/beam/break.c
+++ b/erts/emulator/beam/break.c
@@ -394,8 +394,12 @@ print_process_info(fmtfn_t to, void *to_arg, Process *p, ErtsProcLocks orig_lock
erts_print(to, to_arg, "OldBinVHeap: %b64u\n", BIN_OLD_VHEAP(p));
erts_print(to, to_arg, "BinVHeap unused: %b64u\n",
BIN_VHEAP_SZ(p) - p->off_heap.overhead);
- erts_print(to, to_arg, "OldBinVHeap unused: %b64u\n",
- BIN_OLD_VHEAP_SZ(p) - BIN_OLD_VHEAP(p));
+ if (BIN_OLD_VHEAP_SZ(p) >= BIN_OLD_VHEAP(p)) {
+ erts_print(to, to_arg, "OldBinVHeap unused: %b64u\n",
+ BIN_OLD_VHEAP_SZ(p) - BIN_OLD_VHEAP(p));
+ } else {
+ erts_print(to, to_arg, "OldBinVHeap unused: overflow\n");
+ }
erts_print(to, to_arg, "Memory: %beu\n", erts_process_memory(p, !0));
if (garbing) {
diff --git a/erts/emulator/beam/bs_instrs.tab b/erts/emulator/beam/bs_instrs.tab
index 9cad2b03c5..bd1ad91e45 100644
--- a/erts/emulator/beam/bs_instrs.tab
+++ b/erts/emulator/beam/bs_instrs.tab
@@ -125,7 +125,7 @@ BS_GET_UNCHECKED_FIELD_SIZE(Bits, Unit, Fail, Dst) {
TEST_BIN_VHEAP(VNh, Nh, Live) {
Uint need = $Nh;
if (E - HTOP < need || MSO(c_p).overhead + $VNh >= BIN_VHEAP_SZ(c_p)) {
- SWAPOUT;
+ $GC_SWAPOUT();
PROCESS_MAIN_CHK_LOCKS(c_p);
FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, $Live, FCALLS);
ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p);
diff --git a/erts/emulator/beam/instrs.tab b/erts/emulator/beam/instrs.tab
index 692408e212..462ee77e6f 100644
--- a/erts/emulator/beam/instrs.tab
+++ b/erts/emulator/beam/instrs.tab
@@ -1001,7 +1001,7 @@ catch_end(Y) {
}
/* only x(2) is included in the rootset here */
if (E - HTOP < 3) {
- SWAPOUT;
+ $GC_SWAPOUT();
PROCESS_MAIN_CHK_LOCKS(c_p);
FCALLS -= erts_garbage_collect_nobump(c_p, 3, reg+2, 1, FCALLS);
ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p);
diff --git a/erts/emulator/beam/macros.tab b/erts/emulator/beam/macros.tab
index 494fe8961e..1b5e5f66b0 100644
--- a/erts/emulator/beam/macros.tab
+++ b/erts/emulator/beam/macros.tab
@@ -63,10 +63,21 @@ JUMP(Fail) {
Goto(*I);
}
+GC_SWAPOUT() {
+ //
+ // Since a garbage collection is expensive anyway, we can afford
+ // to save the instruction counter so that the correct function will
+ // be pointed in the crash dump if the garbage collection fails
+ // because of insufficient memory.
+ //
+ SWAPOUT;
+ c_p->i = I;
+}
+
GC_TEST(Ns, Nh, Live) {
Uint need = $Nh + $Ns;
if (ERTS_UNLIKELY(E - HTOP < need)) {
- SWAPOUT;
+ $GC_SWAPOUT();
PROCESS_MAIN_CHK_LOCKS(c_p);
FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, $Live, FCALLS);
ERTS_VERIFY_UNUSED_TEMP_ALLOC(c_p);
@@ -79,7 +90,7 @@ GC_TEST(Ns, Nh, Live) {
GC_TEST_PRESERVE(NeedHeap, Live, PreserveTerm) {
Uint need = $NeedHeap;
if (ERTS_UNLIKELY(E - HTOP < need)) {
- SWAPOUT;
+ $GC_SWAPOUT();
reg[$Live] = $PreserveTerm;
PROCESS_MAIN_CHK_LOCKS(c_p);
FCALLS -= erts_garbage_collect_nobump(c_p, need, reg, $Live+1, FCALLS);
diff --git a/erts/emulator/test/Makefile b/erts/emulator/test/Makefile
index 28775b6f02..019af2162f 100644
--- a/erts/emulator/test/Makefile
+++ b/erts/emulator/test/Makefile
@@ -207,14 +207,10 @@ ERL_COMPILE_FLAGS +=
# ----------------------------------------------------
make_emakefile: $(NO_OPT_ERL_FILES) $(NATIVE_ERL_FILES)
- # This special rule can be removed when communication with R7B nodes
- # is no longer supported.
- $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) +compressed -o$(EBIN) \
- '*_SUITE_make' > $(EMAKEFILE)
$(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) +compressed -o$(EBIN) \
$(MODULES) >> $(EMAKEFILE)
- $(ERL_TOP)/make/make_emakefile +no_copt +no_postopt $(ERL_COMPILE_FLAGS) \
- -o$(EBIN) $(NO_OPT_MODULES) >> $(EMAKEFILE)
+ $(ERL_TOP)/make/make_emakefile +no_copt +no_postopt +no_ssa_opt +no_bsm_opt \
+ $(ERL_COMPILE_FLAGS) -o$(EBIN) $(NO_OPT_MODULES) >> $(EMAKEFILE)
$(ERL_TOP)/make/make_emakefile +native $(ERL_COMPILE_FLAGS) \
-o$(EBIN) $(NATIVE_MODULES) >> $(EMAKEFILE)
diff --git a/erts/emulator/test/bs_construct_SUITE.erl b/erts/emulator/test/bs_construct_SUITE.erl
index ad05cb3689..8fab4f5bc4 100644
--- a/erts/emulator/test/bs_construct_SUITE.erl
+++ b/erts/emulator/test/bs_construct_SUITE.erl
@@ -16,8 +16,6 @@
%% limitations under the License.
%%
%% %CopyrightEnd%
-%%
-%% Purpose : Common utilities used by several optimization passes.
%%
-module(bs_construct_SUITE).
@@ -27,9 +25,9 @@
test1/1, test2/1, test3/1, test4/1, test5/1, testf/1,
not_used/1, in_guard/1,
mem_leak/1, coerce_to_float/1, bjorn/1, append_empty_is_same/1,
- huge_float_field/1, huge_binary/1, system_limit/1, badarg/1,
+ huge_float_field/1, system_limit/1, badarg/1,
copy_writable_binary/1, kostis/1, dynamic/1, bs_add/1,
- otp_7422/1, zero_width/1, bad_append/1, bs_add_overflow/1]).
+ otp_7422/1, zero_width/1, bad_append/1, bs_append_overflow/1]).
-include_lib("common_test/include/ct.hrl").
@@ -40,9 +38,9 @@ suite() ->
all() ->
[test1, test2, test3, test4, test5, testf, not_used,
in_guard, mem_leak, coerce_to_float, bjorn, append_empty_is_same,
- huge_float_field, huge_binary, system_limit, badarg,
+ huge_float_field, system_limit, badarg,
copy_writable_binary, kostis, dynamic, bs_add, otp_7422, zero_width,
- bad_append, bs_add_overflow].
+ bad_append, bs_append_overflow].
init_per_suite(Config) ->
Config.
@@ -543,56 +541,6 @@ huge_float_field(Config) when is_list(Config) ->
huge_float_check({'EXIT',{system_limit,_}}) -> ok;
huge_float_check({'EXIT',{badarg,_}}) -> ok.
-huge_binary(Config) when is_list(Config) ->
- ct:timetrap({seconds, 60}),
- 16777216 = size(<<0:(id(1 bsl 26)),(-1):(id(1 bsl 26))>>),
- garbage_collect(),
- FreeMem = free_mem(),
- io:format("Free memory (Mb): ~p\n", [FreeMem]),
- {Shift,Return} = case free_mem() of
- undefined ->
- %% This test has to be inlined inside the case to
- %% use a literal Shift
- garbage_collect(),
- id(<<0:((1 bsl 32)-1)>>),
- {32,ok};
- Mb when Mb > 600 ->
- garbage_collect(),
- id(<<0:((1 bsl 32)-1)>>),
- {32,ok};
- Mb when Mb > 300 ->
- garbage_collect(),
- id(<<0:((1 bsl 31)-1)>>),
- {31,"Limit huge binaries to 256 Mb"};
- Mb when Mb > 200 ->
- garbage_collect(),
- id(<<0:((1 bsl 30)-1)>>),
- {30,"Limit huge binary to 128 Mb"};
- _ ->
- garbage_collect(),
- id(<<0:((1 bsl 29)-1)>>),
- {29,"Limit huge binary to 64 Mb"}
- end,
- garbage_collect(),
- id(<<0:((1 bsl Shift)-1)>>),
- garbage_collect(),
- id(<<0:(id((1 bsl Shift)-1))>>),
- garbage_collect(),
- case Return of
- ok -> ok;
- Comment -> {comment, Comment}
- end.
-
-%% Return the amount of free memory in Mb.
-free_mem() ->
- {ok,Apps} = application:ensure_all_started(os_mon),
- Mem = memsup:get_system_memory_data(),
- [ok = application:stop(App)||App <- Apps],
- case proplists:get_value(free_memory,Mem) of
- undefined -> undefined;
- Val -> Val div (1024*1024)
- end.
-
system_limit(Config) when is_list(Config) ->
WordSize = erlang:system_info(wordsize),
BitsPerWord = WordSize * 8,
@@ -904,33 +852,37 @@ append_unit_8(Bin) ->
append_unit_16(Bin) ->
<<Bin/binary-unit:16,0:1>>.
-%% Produce a large result of bs_add that, if cast to signed int, would overflow
-%% into a negative number that fits a smallnum.
-bs_add_overflow(_Config) ->
+%% Test that the bs_append instruction will correctly check for
+%% overflow by producing a binary whose total size would exceed the
+%% maximum allowed size for a binary on a 32-bit computer.
+
+bs_append_overflow(_Config) ->
Memsize = memsize(),
io:format("Memsize = ~w Bytes~n", [Memsize]),
case erlang:system_info(wordsize) of
8 ->
+ %% Not possible to test on a 64-bit computer.
{skip, "64-bit architecture"};
_ when Memsize < (2 bsl 30) ->
- {skip, "Less then 2 GB of memory"};
+ {skip, "Less than 2 GB of memory"};
4 ->
- {'EXIT', {system_limit, _}} = (catch bs_add_overflow_signed()),
- {'EXIT', {system_limit, _}} = (catch bs_add_overflow_unsigned()),
+ {'EXIT', {system_limit, _}} = (catch bs_append_overflow_signed()),
+ erlang:garbage_collect(),
+ {'EXIT', {system_limit, _}} = (catch bs_append_overflow_unsigned()),
+ erlang:garbage_collect(),
ok
end.
-bs_add_overflow_signed() ->
- %% Produce a large result of bs_add that, if cast to signed int, would
+bs_append_overflow_signed() ->
+ %% Produce a large binary that, if cast to signed int, would
%% overflow into a negative number that fits a smallnum.
Large = <<0:((1 bsl 30)-1)>>,
<<Large/bits, Large/bits, Large/bits, Large/bits,
Large/bits, Large/bits, Large/bits, Large/bits,
Large/bits>>.
-bs_add_overflow_unsigned() ->
- %% Produce a large result of bs_add that goes beyond the limit of an
- %% unsigned word. This used to succeed but produced an incorrect result
+bs_append_overflow_unsigned() ->
+ %% The following would succeed but would produce an incorrect result
%% where B =:= C!
A = <<0:((1 bsl 32)-8)>>,
B = <<2, 3>>,
diff --git a/erts/emulator/test/bs_match_int_SUITE.erl b/erts/emulator/test/bs_match_int_SUITE.erl
index e913dc98b0..454e55d017 100644
--- a/erts/emulator/test/bs_match_int_SUITE.erl
+++ b/erts/emulator/test/bs_match_int_SUITE.erl
@@ -234,34 +234,49 @@ mml_choose(<<_A:8>>) -> single_byte_binary;
mml_choose(<<_A:8,_T/binary>>) -> multi_byte_binary.
match_huge_int(Config) when is_list(Config) ->
- Sz = 1 bsl 27,
- Bin = <<0:Sz,13:8>>,
- skip_huge_int_1(Sz, Bin),
- 0 = match_huge_int_1(Sz, Bin),
-
- %% Test overflowing the size of an integer field.
- nomatch = overflow_huge_int_skip_32(Bin),
- case erlang:system_info(wordsize) of
- 4 ->
- nomatch = overflow_huge_int_32(Bin);
- 8 ->
- %% An attempt will be made to allocate heap space for
- %% the bignum (which will probably fail); only if the
- %% allocation succeeds will the matching fail because
- %% the binary is too small.
- ok
- end,
- nomatch = overflow_huge_int_skip_64(Bin),
- nomatch = overflow_huge_int_64(Bin),
-
- %% Test overflowing the size of an integer field using variables as sizes.
- Sizes = case erlang:system_info(wordsize) of
- 4 -> lists:seq(25, 32);
- 8 -> []
- end ++ lists:seq(50, 64),
- ok = overflow_huge_int_unit128(Bin, Sizes),
-
- ok.
+ case ?MODULE of
+ bs_match_int_no_opt_SUITE ->
+ %% This test case is written with the assumption that
+ %% bs_skip2 instructions are used when the value of the
+ %% extracted segment will not be used. In OTP 21 and earlier, that
+ %% assumption was always true, because the bs_skip optimization
+ %% was included in v3_codegen and could not be disabled.
+ %% In OTP 22, the bs_skip optimization is done by beam_ssa_opt
+ %% and is disabled.
+ %%
+ %% On memory-constrained computers, using bs_get_integer2
+ %% instructions may cause the runtime system to terminate
+ %% because of insufficient memory.
+ {skip, "unoptimized code would use too much memory"};
+ bs_match_int_SUITE ->
+ Sz = 1 bsl 27,
+ Bin = <<0:Sz,13:8>>,
+ skip_huge_int_1(Sz, Bin),
+ 0 = match_huge_int_1(Sz, Bin),
+
+ %% Test overflowing the size of an integer field.
+ nomatch = overflow_huge_int_skip_32(Bin),
+ case erlang:system_info(wordsize) of
+ 4 ->
+ nomatch = overflow_huge_int_32(Bin);
+ 8 ->
+ %% An attempt will be made to allocate heap space for
+ %% the bignum (which will probably fail); only if the
+ %% allocation succeeds will the matching fail because
+ %% the binary is too small.
+ ok
+ end,
+ nomatch = overflow_huge_int_skip_64(Bin),
+ nomatch = overflow_huge_int_64(Bin),
+
+ %% Test overflowing the size of an integer field using
+ %% variables as sizes.
+ Sizes = case erlang:system_info(wordsize) of
+ 4 -> lists:seq(25, 32);
+ 8 -> []
+ end ++ lists:seq(50, 64),
+ ok = overflow_huge_int_unit128(Bin, Sizes)
+ end.
overflow_huge_int_unit128(Bin, [Sz0|Sizes]) ->
Sz = id(1 bsl Sz0),
diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl
index 58194cf167..6e31c73e10 100644
--- a/erts/emulator/test/distribution_SUITE.erl
+++ b/erts/emulator/test/distribution_SUITE.erl
@@ -19,7 +19,6 @@
%%
-module(distribution_SUITE).
--compile(r16).
-define(VERSION_MAGIC, 131).
@@ -55,7 +54,6 @@
dist_parallel_send/1,
atom_roundtrip/1,
unicode_atom_roundtrip/1,
- atom_roundtrip_r16b/1,
contended_atom_cache_entry/1,
contended_unicode_atom_cache_entry/1,
bad_dist_structure/1,
@@ -95,7 +93,6 @@ all() ->
ref_port_roundtrip, nil_roundtrip, stop_dist,
{group, trap_bif}, {group, dist_auto_connect},
dist_parallel_send, atom_roundtrip, unicode_atom_roundtrip,
- atom_roundtrip_r16b,
contended_atom_cache_entry, contended_unicode_atom_cache_entry,
{group, message_latency},
{group, bad_dist}, {group, bad_dist_ext},
@@ -1158,23 +1155,6 @@ atom_roundtrip(Config) when is_list(Config) ->
stop_node(Node),
ok.
-atom_roundtrip_r16b(Config) when is_list(Config) ->
- case test_server:is_release_available("r16b") of
- true ->
- ct:timetrap({minutes, 6}),
- AtomData = unicode_atom_data(),
- verify_atom_data(AtomData),
- case start_node(Config, [], "r16b") of
- {ok, Node} ->
- do_atom_roundtrip(Node, AtomData),
- stop_node(Node);
- {error, timeout} ->
- {skip,"Unable to start OTP R16B release"}
- end;
- false ->
- {skip,"No OTP R16B available"}
- end.
-
unicode_atom_roundtrip(Config) when is_list(Config) ->
AtomData = unicode_atom_data(),
verify_atom_data(AtomData),
diff --git a/erts/emulator/test/erts_test_utils.erl b/erts/emulator/test/erts_test_utils.erl
index e4e00a0a16..9c9eaa70ed 100644
--- a/erts/emulator/test/erts_test_utils.erl
+++ b/erts/emulator/test/erts_test_utils.erl
@@ -19,7 +19,7 @@
%%
-module(erts_test_utils).
--compile(r16).
+-compile(r20).
%%
%% THIS MODULE IS ALSO USED BY *OTHER* APPLICATIONS TEST CODE
diff --git a/erts/emulator/test/fun_SUITE.erl b/erts/emulator/test/fun_SUITE.erl
index 7f6caa08f1..2cbde621ce 100644
--- a/erts/emulator/test/fun_SUITE.erl
+++ b/erts/emulator/test/fun_SUITE.erl
@@ -513,6 +513,8 @@ refc(Config) when is_list(Config) ->
Other -> ct:fail({unexpected,Other})
end,
process_flag(trap_exit, false),
+ %% Wait to make sure that the process has terminated completely.
+ receive after 1 -> ok end,
{refc,3} = erlang:fun_info(F1, refc),
%% Garbage collect. Only the F2 fun will be left.