diff options
author | Erlang/OTP <[email protected]> | 2017-01-12 15:16:02 +0100 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2017-01-12 15:16:02 +0100 |
commit | 905e6ea8c21e8bcba0933a147ef70f7044e6bead (patch) | |
tree | 341bb2f6a854b22d3c94f64a9a8c93ee9a4564cf /erts/emulator/beam/beam_bif_load.c | |
parent | 3473ecd83a7bbe7e0bebb865f25dddb93e3bf10f (diff) | |
parent | af5169d85fcd545e3c857a219db081a62f33404d (diff) | |
download | otp-905e6ea8c21e8bcba0933a147ef70f7044e6bead.tar.gz otp-905e6ea8c21e8bcba0933a147ef70f7044e6bead.tar.bz2 otp-905e6ea8c21e8bcba0933a147ef70f7044e6bead.zip |
Merge branch 'sverker/make-export-fun-race/OTP-14144' into maint-19
* sverker/make-export-fun-race/OTP-14144:
erts: Fix race bug between export fun creation and code loading
Diffstat (limited to 'erts/emulator/beam/beam_bif_load.c')
-rw-r--r-- | erts/emulator/beam/beam_bif_load.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c index ea1323d651..dbff005325 100644 --- a/erts/emulator/beam/beam_bif_load.c +++ b/erts/emulator/beam/beam_bif_load.c @@ -786,7 +786,7 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2) } if (BIF_ARG_2 == am_true) { - int i; + int i, num_exps; /* * Make the code with the on_load function current. @@ -802,7 +802,8 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2) /* * The on_load function succeded. Fix up export entries. */ - for (i = 0; i < export_list_size(code_ix); i++) { + num_exps = export_list_size(code_ix); + for (i = 0; i < num_exps; i++) { Export *ep = export_list(i,code_ix); if (ep == NULL || ep->code[0] != BIF_ARG_1) { continue; @@ -822,14 +823,15 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2) modp->curr.code_hdr->on_load_function_ptr = NULL; set_default_trace_pattern(BIF_ARG_1); } else if (BIF_ARG_2 == am_false) { - int i; + int i, num_exps; /* * The on_load function failed. Remove references to the * code that is about to be purged from the export entries. */ - for (i = 0; i < export_list_size(code_ix); i++) { + num_exps = export_list_size(code_ix); + for (i = 0; i < num_exps; i++) { Export *ep = export_list(i,code_ix); if (ep == NULL || ep->code[0] != BIF_ARG_1) { continue; @@ -2022,9 +2024,9 @@ delete_code(Module* modp) { ErtsCodeIndex code_ix = erts_staging_code_ix(); Eterm module = make_atom(modp->module); - int i; + int i, num_exps = export_list_size(code_ix); - for (i = 0; i < export_list_size(code_ix); i++) { + for (i = 0; i < num_exps; i++) { Export *ep = export_list(i, code_ix); if (ep != NULL && (ep->code[0] == module)) { if (ep->addressv[code_ix] == ep->code+3) { |