From 790ac0003ce854943cdac85b4843f20410b0bd5a Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 2 Apr 2019 16:42:26 +0200 Subject: erts: Fix gcc warning in to_erl --- erts/etc/unix/to_erl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/etc/unix/to_erl.c b/erts/etc/unix/to_erl.c index ed4fe12e8b..1448980f77 100644 --- a/erts/etc/unix/to_erl.c +++ b/erts/etc/unix/to_erl.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) if (len) { #ifdef DEBUG - (void)write(1, buf, len); + write_all(1, buf, len); #endif if (write_all(wfd, buf, len) != len) { fprintf(stderr, "Error in writing to FIFO.\n"); -- cgit v1.2.3 From d39dc911688a9cba609cb1d3747a356e351531ba Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 2 Apr 2019 17:03:47 +0200 Subject: erts: Make erts_free debug failure easier to diagnose --- erts/emulator/beam/erl_alloc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'erts') diff --git a/erts/emulator/beam/erl_alloc.c b/erts/emulator/beam/erl_alloc.c index e6169ebeaa..b9f0334172 100644 --- a/erts/emulator/beam/erl_alloc.c +++ b/erts/emulator/beam/erl_alloc.c @@ -3904,7 +3904,7 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func) { Uint sz; Uint found_type; - UWord pre_pattern; + UWord pre_pattern, expected_pattern; UWord post_pattern; UWord *ui_ptr; #ifdef HARD_DEBUG @@ -3914,6 +3914,8 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func) if (!ptr) return NULL; + expected_pattern = MK_PATTERN(n); + ui_ptr = (UWord *) ptr; pre_pattern = *(--ui_ptr); *size = sz = *(--ui_ptr); @@ -3922,7 +3924,13 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func) #endif found_type = GET_TYPE_OF_PATTERN(pre_pattern); - if (pre_pattern != MK_PATTERN(n)) { + + if (found_type != n) { + erts_exit(ERTS_ABORT_EXIT, "ERROR: Miss matching allocator types" + " used in alloc and free\n"); + } + + if (pre_pattern != expected_pattern) { if ((FIXED_FENCE_PATTERN_MASK & pre_pattern) != FIXED_FENCE_PATTERN) erts_exit(ERTS_ABORT_EXIT, "ERROR: Fence at beginning of memory block (p=0x%u) " @@ -3932,8 +3940,7 @@ check_memory_fence(void *ptr, Uint *size, ErtsAlcType_t n, int func) sys_memcpy((void *) &post_pattern, (void *) (((char *)ptr)+sz), sizeof(UWord)); - if (post_pattern != MK_PATTERN(n) - || pre_pattern != post_pattern) { + if (post_pattern != expected_pattern || pre_pattern != post_pattern) { char fbuf[10]; char obuf[10]; char *ftype; -- cgit v1.2.3 From 2fb91a49a55554ec1a9de7256c7e285860b4048a Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 3 Apr 2019 09:30:05 +0200 Subject: vxworks: Make vxworks configure use environment CFLAGS --- erts/autoconf/configure.vxworks | 1 + erts/autoconf/vxworks/sed.general | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/autoconf/configure.vxworks b/erts/autoconf/configure.vxworks index 1893f3f7e0..c3bdfd0095 100755 --- a/erts/autoconf/configure.vxworks +++ b/erts/autoconf/configure.vxworks @@ -135,6 +135,7 @@ for file in $CONFIG_FILES; do -e "s,@HOST_TYPE@,$HOST_TYPE,g" \ -e "s,@WIND_BASE@,$WIND_BASE,g" \ -e "s,@TARGET@,$target,g" \ + -e "s,@ENV_CFLAGS@,$CFLAGS,g" \ $in_file > $new_name done diff --git a/erts/autoconf/vxworks/sed.general b/erts/autoconf/vxworks/sed.general index d32fbdc5c0..ffd5a8133c 100644 --- a/erts/autoconf/vxworks/sed.general +++ b/erts/autoconf/vxworks/sed.general @@ -111,7 +111,7 @@ s|@erlexec@|erl.exec| s|@EMU_LIBOBJS@|| # General CFLAGS -s|@GENERAL_CFLAGS@|-DHAVE_LOCALTIME_R -DHAVE_GMTIME_R -DENABLE_ELIB_MALLOC -DELIB_HEAP_USER -DELIB_SORTED_BLOCKS -DWORDS_BIGENDIAN -DELIB_DONT_INITIALIZE -DSIZEOF_CHAR=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DSIZEOF_VOID_P=4 -DERTS_USE_PORT_TASKS=1|g +s|@GENERAL_CFLAGS@|@ENV_CFLAGS@ -DHAVE_LOCALTIME_R -DHAVE_GMTIME_R -DENABLE_ELIB_MALLOC -DELIB_HEAP_USER -DELIB_SORTED_BLOCKS -DWORDS_BIGENDIAN -DELIB_DONT_INITIALIZE -DSIZEOF_CHAR=1 -DSIZEOF_SHORT=2 -DSIZEOF_INT=4 -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DSIZEOF_VOID_P=4 -DERTS_USE_PORT_TASKS=1|g s|@WFLAGS@|| # Thread flags for eidefs.mk (erl_interface) -- cgit v1.2.3 From e0ee9063f356cf566808fc59f603551651847315 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 8 Apr 2019 14:34:17 +0200 Subject: erts: Fix z_SUITE to always look for cerl in ERL_TOP If it cannot be found in the daily build dir, we try ERL_TOP incase it is there. --- erts/test/z_SUITE.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'erts') diff --git a/erts/test/z_SUITE.erl b/erts/test/z_SUITE.erl index 6a34299dd2..536212af2e 100644 --- a/erts/test/z_SUITE.erl +++ b/erts/test/z_SUITE.erl @@ -88,10 +88,10 @@ find_cerl(DBTop) -> [Cerl | _ ] -> case filelib:is_regular(Cerl) of true -> Cerl; - _ -> false + _ -> find_cerl(false) end; _ -> - false + find_cerl(false) end. is_dir(false) -> -- cgit v1.2.3 From 3e9c74400d20d95e9bbc378478dc00cbafba6b47 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 12 Apr 2019 10:42:39 +0200 Subject: erts: Run smaller dist frag test to 32 bit machines Because of fragmentation of memory it is not always possible to allocate enough 320 MB segments on 32-bit so we only sent smaller packets there. --- erts/emulator/test/distribution_SUITE.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'erts') diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl index 58194cf167..c8f190d29d 100644 --- a/erts/emulator/test/distribution_SUITE.erl +++ b/erts/emulator/test/distribution_SUITE.erl @@ -1480,11 +1480,14 @@ measure_latency_large_message(Nodename, DataFun) -> Echo = spawn(N, fun F() -> receive {From, Msg} -> From ! Msg, F() end end), - case erlang:system_info(build_type) of - debug -> + BuildType = erlang:system_info(build_type), + WordSize = erlang:system_info(wordsize), + + if + BuildType =/= opt; WordSize =:= 4 -> %% Test 3.2 MB and 32 MB and test the latency difference of sent messages Payloads = [{I, <<0:(I * 32 * 1024 * 8)>>} || I <- [1,10]]; - _ -> + true -> %% Test 32 MB and 320 MB and test the latency difference of sent messages Payloads = [{I, <<0:(I * 32 * 1024 * 1024 * 8)>>} || I <- [1,10]] end, @@ -1499,7 +1502,7 @@ measure_latency_large_message(Nodename, DataFun) -> stop_node(N), case {lists:max(Times), lists:min(Times)} of - {Max, Min} when Max * 0.25 > Min -> + {Max, Min} when Max * 0.25 > Min, BuildType =:= opt -> ct:fail({incorrect_latency, IndexTimes}); _ -> ok -- cgit v1.2.3 From 8cba01c623eeb962298750d60bf22f6d6f5538dc Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 12 Apr 2019 11:21:49 +0200 Subject: erts: Add extra debugging to dist frag testcases --- erts/emulator/test/distribution_SUITE.erl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'erts') diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl index c8f190d29d..d1d1e3840e 100644 --- a/erts/emulator/test/distribution_SUITE.erl +++ b/erts/emulator/test/distribution_SUITE.erl @@ -1527,13 +1527,19 @@ measure_latency(DataFun, Dropper, Echo, Payload) -> ok end || _ <- lists:seq(1,10)], - {TS, _} = + {TS, Times} = timer:tc(fun() -> [begin + T0 = erlang:monotonic_time(), Echo ! {self(), hello}, - receive hello -> ok end + receive hello -> ok end, + (erlang:monotonic_time() - T0) / 1000000 end || _ <- lists:seq(1,100)] end), + Avg = lists:sum(Times) / length(Times), + StdDev = math:sqrt(lists:sum([math:pow(V - Avg,2) || V <- Times]) / length(Times)), + ct:pal("Times: Avg: ~p Max: ~p Min: ~p Var: ~p", + [Avg, lists:max(Times), lists:min(Times), StdDev]), [begin Sender ! die, receive -- cgit v1.2.3 From 94f7912c4a12a2a1ab325f62daebfe1b31fe101f Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 12 Apr 2019 11:48:22 +0200 Subject: erts: Make dump_SUITE:free_dump not dump via rpc Doing the dump via rpc can introduce all kins of strange timing issiues. So instead we dump 5ms after the exit has been started. --- erts/emulator/test/dump_SUITE.erl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'erts') diff --git a/erts/emulator/test/dump_SUITE.erl b/erts/emulator/test/dump_SUITE.erl index 3b860ebdf6..2440833992 100644 --- a/erts/emulator/test/dump_SUITE.erl +++ b/erts/emulator/test/dump_SUITE.erl @@ -146,7 +146,7 @@ free_dump(Config) when is_list(Config) -> Self ! ready, receive ok -> - unlink(Self), + spawn(fun() -> timer:sleep(5), erlang:halt("dump") end), exit(lists:duplicate(1000,1000)) end end), @@ -156,8 +156,6 @@ free_dump(Config) when is_list(Config) -> [erlang:monitor(process, Pid) || _ <- lists:seq(1,10000)], receive ready -> unlink(Pid), Pid ! ok end, - rpc:call(Node, erlang, halt, ["dump"]), - {ok, Bin} = get_dump_when_done(Dump), {match, Matches} = re:run(Bin,"^State: Non Existing", [global, multiline]), -- cgit v1.2.3 From bea8399d5d4b54ec2c77d86921885eb9539b00d6 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 15 Apr 2019 11:28:58 +0200 Subject: erts: Fix cleanup of message factory undo --- erts/emulator/beam/erl_message.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'erts') diff --git a/erts/emulator/beam/erl_message.c b/erts/emulator/beam/erl_message.c index 2a0fb9e2aa..6645341512 100644 --- a/erts/emulator/beam/erl_message.c +++ b/erts/emulator/beam/erl_message.c @@ -1590,6 +1590,9 @@ void erts_factory_undo(ErtsHeapFactory* factory) factory->message->hfrag.next = factory->heap_frags; else factory->message->data.heap_frag = factory->heap_frags; + /* Set the message to NIL in order for this message not to be + treated as a distributed message by the cleanup_messages logic */ + factory->message->m[0] = NIL; erts_cleanup_messages(factory->message); break; case FACTORY_TMP: -- cgit v1.2.3 From 290a5b02b9c9d66729ac87b7099a8ca6fa2e8bc2 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 15 Apr 2019 11:29:50 +0200 Subject: erts: Fix etp-process-info to print exiting and free processes --- erts/etc/unix/etp-commands.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/etc/unix/etp-commands.in b/erts/etc/unix/etp-commands.in index dc28107ef5..36786aa302 100644 --- a/erts/etc/unix/etp-commands.in +++ b/erts/etc/unix/etp-commands.in @@ -2090,7 +2090,7 @@ define etp-process-info-int etp-pid2proc-1 $etp_proc->common.id etp-process-info $proc else - if (*(((Uint32 *) &($etp_proc->state))) & 0x4) == 0 + if (*(((Uint32 *) &($etp_proc->state))) & 0x800) == 0 if ($etp_proc->common.u.alive.reg) printf " Registered name: " etp-1 $etp_proc->common.u.alive.reg->name -- cgit v1.2.3 From 37e307235abf4ceb3dd4f4f59a3bae7e187e091d Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 15 Apr 2019 11:34:39 +0200 Subject: erts: Fix cerl -rr to use correct etp file --- erts/etc/unix/cerl.src | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src index bcd64d242e..8cfc2d549e 100644 --- a/erts/etc/unix/cerl.src +++ b/erts/etc/unix/cerl.src @@ -320,7 +320,7 @@ if [ "x$GDB" = "x" ]; then if [ "$1" = "-p" ]; then echo 'set $etp_rr_run_until_beam = 1' >> $cmdfile fi - cat $ROOTDIR/erts/etc/unix/etp-commands.in >> $cmdfile + cat $ROOTDIR/erts/etc/unix/etp-commands >> $cmdfile exec rr replay -x $cmdfile $* elif [ $1 = ps ]; then shift -- cgit v1.2.3 From bc39fa234dd2d2834985dcdd37159cbc9e4d8a51 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 15 Apr 2019 17:02:32 +0200 Subject: erts: Yield correctly when iterating over distr exit messages Before this fix the process would continue to process more distributed down or exit messages until it ran out of reductions instead of being suspended immediately. --- erts/emulator/beam/erl_process.c | 10 +++++-- erts/emulator/test/distribution_SUITE.erl | 2 +- erts/emulator/test/dump_SUITE.erl | 49 +++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 18 deletions(-) (limited to 'erts') diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index 2b45d2d353..76eec96372 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -12095,6 +12095,7 @@ erts_proc_exit_handle_dist_monitor(ErtsMonitor *mon, void *vctxt, Sint reds) Eterm watched; Uint watcher_sz, ref_sz; ErtsHeapFactory factory; + Sint reds_consumed = 0; ASSERT(erts_monitor_is_target(mon) && mon->type == ERTS_MON_TYPE_DIST_PROC); @@ -12139,11 +12140,13 @@ erts_proc_exit_handle_dist_monitor(ErtsMonitor *mon, void *vctxt, Sint reds) watched, ref, reason); + reds_consumed = reds - (ctx.reds / TERM_TO_BINARY_LOOP_FACTOR); switch (code) { case ERTS_DSIG_SEND_CONTINUE: case ERTS_DSIG_SEND_YIELD: erts_set_gc_state(c_p, 0); ctxt->dist_state = erts_dsend_export_trap_context(c_p, &ctx); + reds_consumed = reds; /* force yield */ break; case ERTS_DSIG_SEND_OK: break; @@ -12163,7 +12166,7 @@ erts_proc_exit_handle_dist_monitor(ErtsMonitor *mon, void *vctxt, Sint reds) erts_monitor_release(mon); else erts_monitor_release_both(mdp); - return reds - (ctx.reds / TERM_TO_BINARY_LOOP_FACTOR); + return reds_consumed; } int @@ -12350,6 +12353,7 @@ erts_proc_exit_handle_dist_link(ErtsLink *lnk, void *vctxt, Sint reds) ErtsLink *dlnk; ErtsLinkData *ldp = NULL; ErtsHeapFactory factory; + Sint reds_consumed = 0; ASSERT(lnk->type == ERTS_LNK_TYPE_DIST_PROC); dlnk = erts_link_to_other(lnk, &ldp); @@ -12386,11 +12390,13 @@ erts_proc_exit_handle_dist_link(ErtsLink *lnk, void *vctxt, Sint reds) item, reason, SEQ_TRACE_TOKEN(c_p)); + reds_consumed = reds - (ctx.reds / TERM_TO_BINARY_LOOP_FACTOR); switch (code) { case ERTS_DSIG_SEND_YIELD: case ERTS_DSIG_SEND_CONTINUE: erts_set_gc_state(c_p, 0); ctxt->dist_state = erts_dsend_export_trap_context(c_p, &ctx); + reds_consumed = reds; /* force yield */ break; case ERTS_DSIG_SEND_OK: break; @@ -12410,7 +12416,7 @@ erts_proc_exit_handle_dist_link(ErtsLink *lnk, void *vctxt, Sint reds) erts_link_release_both(ldp); else if (lnk) erts_link_release(lnk); - return reds - (ctx.reds / TERM_TO_BINARY_LOOP_FACTOR); + return reds_consumed; } int diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl index d1d1e3840e..84e95e6d26 100644 --- a/erts/emulator/test/distribution_SUITE.erl +++ b/erts/emulator/test/distribution_SUITE.erl @@ -77,7 +77,7 @@ optimistic_dflags_echo/0, optimistic_dflags_sender/1, roundtrip/1, bounce/1, do_dist_auto_connect/1, inet_rpc_server/1, dist_parallel_sender/3, dist_parallel_receiver/0, - dist_evil_parallel_receiver/0]). + dist_evil_parallel_receiver/0, make_busy/2]). %% epmd_module exports -export([start_link/0, register_node/2, register_node/3, port_please/2, address_please/3]). diff --git a/erts/emulator/test/dump_SUITE.erl b/erts/emulator/test/dump_SUITE.erl index 2440833992..9f8ac42fa9 100644 --- a/erts/emulator/test/dump_SUITE.erl +++ b/erts/emulator/test/dump_SUITE.erl @@ -137,24 +137,43 @@ exiting_dump(Config) when is_list(Config) -> free_dump(Config) when is_list(Config) -> Dump = filename:join(proplists:get_value(priv_dir, Config),"signal_abort.dump"), - {ok, Node} = start_node(Config), - - Self = self(), + {ok, NodeA} = start_node(Config), + {ok, NodeB} = start_node(Config), - Pid = spawn_link(Node, - fun() -> - Self ! ready, - receive - ok -> - spawn(fun() -> timer:sleep(5), erlang:halt("dump") end), - exit(lists:duplicate(1000,1000)) - end - end), - true = rpc:call(Node, os, putenv, ["ERL_CRASH_DUMP",Dump]), + Self = self(), - [erlang:monitor(process, Pid) || _ <- lists:seq(1,10000)], - receive ready -> unlink(Pid), Pid ! ok end, + PidA = spawn_link( + NodeA, + fun() -> + Self ! ready, + receive + ok -> + spawn(fun() -> + erlang:system_monitor(self(), [busy_dist_port]), + timer:sleep(5), + receive + M -> + io:format("~p",[M]), + erlang:halt("dump") + end + end), + exit(lists:duplicate(1000000,100)) + end + end), + + spawn_link(NodeB, + fun() -> + [erlang:monitor(process, PidA) || _ <- lists:seq(1,10000)], + Self ! done, + receive _ -> ok end + end), + + receive done -> ok end, + true = rpc:call(NodeA, os, putenv, ["ERL_CRASH_DUMP",Dump]), + ct:pal("~p",[rpc:call(NodeA, distribution_SUITE, make_busy, [NodeB, 1000])]), + + receive ready -> unlink(PidA), PidA ! ok end, {ok, Bin} = get_dump_when_done(Dump), -- cgit v1.2.3