summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2022-02-01 13:29:37 +0100
committerLukas Larsson <lukas@erlang.org>2022-02-11 09:21:37 +0100
commitc1600e9cb1f1e6bcaeb41f941853a23c772f332d (patch)
treec5a96df02e2903ad76662da9f0b95c503cb73c59
parent6d5a5f31c36bbdaad21585d25974177bd1b75e66 (diff)
downloaderlang-c1600e9cb1f1e6bcaeb41f941853a23c772f332d.tar.gz
erts: Fix trace running memory leak
If a process is being tracing using 'running' trace and at the same time polled using erlang:process_info, then the memory allocated for the tracing will never trigger a GC as there are no GC tests for when only signals/sys tasks are run. This commit moves the GC check so that it is done earlier in order to catch any memory allocated when executing signals/sys tasks. The bug is triggered by running etop towards an idle node.
-rw-r--r--erts/emulator/beam/erl_process.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 406336fea7..411734038a 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -9924,6 +9924,17 @@ Process *erts_schedule(ErtsSchedulerData *esdp, Process *p, int calls)
if (((state & (ERTS_PSFLG_SUSPENDED
| ERTS_PSFLG_ACTIVE)) != ERTS_PSFLG_ACTIVE)
& !(state & ERTS_PSFLG_EXITING)) {
+
+ /* Tracing, handling signals and running sys_tasks may
+ have created data on the process heap that should
+ be GC:ed. */
+ if (ERTS_IS_GC_DESIRED(p)
+ && !(p->flags & (F_DELAY_GC|F_DISABLE_GC))) {
+ int cost = scheduler_gc_proc(p, reds);
+ calls += cost;
+ reds -= cost;
+ }
+
goto sched_out_proc;
}