aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-02-21 15:20:49 +0100
committerSverker Eriksson <[email protected]>2012-02-21 15:32:08 +0100
commitcebdde12c16ed51d2d714c4e68c24425f476e1f6 (patch)
tree1ab21202c87e4ac3778bc71ab401204f89c885eb /erts/emulator
parentcd63cd50bae6d98d6d56fa24674f14e7b9457a37 (diff)
downloadotp-cebdde12c16ed51d2d714c4e68c24425f476e1f6.tar.gz
otp-cebdde12c16ed51d2d714c4e68c24425f476e1f6.tar.bz2
otp-cebdde12c16ed51d2d714c4e68c24425f476e1f6.zip
erts: Fix race bug in finish_after_on_load
Must block system before looking up module to not race with other "code upgrader".
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/beam_bif_load.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c
index 6df5774fdb..c8fc7f9d6b 100644
--- a/erts/emulator/beam/beam_bif_load.c
+++ b/erts/emulator/beam/beam_bif_load.c
@@ -576,11 +576,18 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2)
Module* modp;
Eterm on_load;
+ /* ToDo: Use code_ix switch instead */
+
+ erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
+ erts_smp_thr_progress_block();
+
code_ix = erts_active_code_ix();
modp = erts_get_module(BIF_ARG_1, code_ix);
if (!modp || modp->curr.code == 0) {
error:
+ erts_smp_thr_progress_unblock();
+ erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
BIF_ERROR(BIF_P, BADARG);
}
if ((on_load = modp->curr.code[MI_ON_LOAD_FUNCTION_PTR]) == 0) {
@@ -590,11 +597,6 @@ BIF_RETTYPE finish_after_on_load_2(BIF_ALIST_2)
goto error;
}
- erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
- erts_smp_thr_progress_block();
-
- /*SVERK Use code_ix switch instead */
-
if (BIF_ARG_2 == am_true) {
int i;