aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2018-10-18 15:18:58 +0200
committerBjörn Gustavsson <[email protected]>2018-10-19 05:21:59 +0200
commitbc541da07768ab0e11dca183ba235422ae0df593 (patch)
treecb3790955b0c15eeb43fc4bfd1bc1b99457e43c6 /erts/emulator/beam/bif.c
parent04dde143c505da42ca620189cfa1d3400610ebe1 (diff)
downloadotp-bc541da07768ab0e11dca183ba235422ae0df593.tar.gz
otp-bc541da07768ab0e11dca183ba235422ae0df593.tar.bz2
otp-bc541da07768ab0e11dca183ba235422ae0df593.zip
Honor the max heap size when copying literals after purging
When a module has been purged from memory, any literals belonging to that module will be copied to all processes that hold references to them. The max heap size limit would be ignored in the garbage collection initiated when copying literals to a process. If the max heap size was exceeded, the process would typically be terminated in the following garbage collection. Since the process would be killed anyway later, kill the process before copying a literal that would make it exceed its max heap size. While at it, also fix a potential bug in `erlang:garbage_collect/0`. If it was found that the max heap sized had been exceeded while executing `erlang:garbage_collect/0`, the process would enter a kind of zombie state instead of being properly terminated.
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index f18af8bcd7..015c051cc1 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -3622,6 +3622,10 @@ erts_internal_garbage_collect_1(BIF_ALIST_1)
default: BIF_ERROR(BIF_P, BADARG);
}
erts_garbage_collect(BIF_P, 0, NULL, 0);
+ if (ERTS_PROC_IS_EXITING(BIF_P)) {
+ /* The max heap size limit was reached. */
+ return THE_NON_VALUE;
+ }
return am_true;
}