aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_load.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-09-15 10:16:28 +0200
committerBjörn Gustavsson <[email protected]>2016-09-15 10:16:28 +0200
commitfde238fb52133a6c7a2a3f2a2e16f1c1bef62394 (patch)
tree0e553f298c23f508975635a121fbf8356c58ab8a /erts/emulator/beam/beam_load.c
parentcebef1207eca1cdc8c601b172988a74fd0858efa (diff)
parent359e05121dab023585715b0e42506afd94f2e1f1 (diff)
downloadotp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.tar.gz
otp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.tar.bz2
otp-fde238fb52133a6c7a2a3f2a2e16f1c1bef62394.zip
Merge branch 'bjorn/erts/on_load/ERL-240/OTP-13893' into maint
* bjorn/erts/on_load/ERL-240/OTP-13893: erts: Add nif_SUITE:t_on_load erts: Improve nif_SUITE:upgrade test Don't leak old code when loading a modules with an on_load function
Diffstat (limited to 'erts/emulator/beam/beam_load.c')
-rw-r--r--erts/emulator/beam/beam_load.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index f63addb309..0afdedf6c2 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -833,11 +833,20 @@ erts_finish_loading(Binary* magic, Process* c_p,
size = stp->loaded_size;
erts_total_code_size += size;
- if (stp->on_load) {
- inst_p = &mod_tab_p->old;
- } else {
+
+ if (!stp->on_load) {
inst_p = &mod_tab_p->curr;
+ } else {
+ mod_tab_p->on_load =
+ (struct erl_module_instance *)
+ erts_alloc(ERTS_ALC_T_PREPARED_CODE,
+ sizeof(struct erl_module_instance));
+ inst_p = mod_tab_p->on_load;
+ inst_p->nif = 0;
+ inst_p->num_breakpoints = 0;
+ inst_p->num_traced_exports = 0;
}
+
inst_p->code_hdr = stp->hdr;
inst_p->code_length = size;