Skip to content

Commit

Permalink
Fix for gc crash
Browse files Browse the repository at this point in the history
  • Loading branch information
lucioleKi committed Dec 16, 2024
1 parent fabbdad commit b3e93af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion erts/emulator/beam/erl_ptab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,12 @@ erts_ptab_processes_next(Process *c_p, ErtsPTab *ptab, Uint first)
Eterm* hp;
Eterm *hp_end;

#ifdef DEBUG
int max_pids = 1;
#else
int max_pids = MAX(ERTS_BIF_REDS_LEFT(c_p), 1);
#endif

int num_pids = 0;
int n = max_pids * ERTS_PTAB_REDS_MULTIPLIER;
limit = MIN(ptab->r.o.max, first+n);
Expand All @@ -1500,7 +1505,7 @@ erts_ptab_processes_next(Process *c_p, ErtsPTab *ptab, Uint first)
return THE_NON_VALUE;
}

need = n * 2;
need = 3 + max_pids * 2;
hp = HAlloc(c_p, need); /* we need two heap words for each id */
hp_end = hp + need;
res = make_list(hp);
Expand All @@ -1524,6 +1529,7 @@ erts_ptab_processes_next(Process *c_p, ErtsPTab *ptab, Uint first)
scanned = (i - first) / ERTS_PTAB_REDS_MULTIPLIER + 1;

res = TUPLE2(hp, make_small(i), res);
hp += 3;
HRelease(c_p, hp_end, hp);

BUMP_REDS(c_p, scanned);
Expand Down

0 comments on commit b3e93af

Please sign in to comment.