diff options
author | Sverker Eriksson <[email protected]> | 2015-12-16 20:03:32 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-01-13 19:59:54 +0100 |
commit | 79efde2d8503e5055ef9e8afa5d8d63208710b1f (patch) | |
tree | 77342e16ab227d8b9a175f4573305f244d17cceb /erts/emulator/beam/beam_bif_load.c | |
parent | dc54c2a27c41930a18e0c7f2b97eda6cd4a0b1c1 (diff) | |
download | otp-79efde2d8503e5055ef9e8afa5d8d63208710b1f.tar.gz otp-79efde2d8503e5055ef9e8afa5d8d63208710b1f.tar.bz2 otp-79efde2d8503e5055ef9e8afa5d8d63208710b1f.zip |
erts: Make copy_literals more fail safe
* Same process must do enable-disable.
* System process will force it and never get 'aborted'
Diffstat (limited to 'erts/emulator/beam/beam_bif_load.c')
-rw-r--r-- | erts/emulator/beam/beam_bif_load.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/erts/emulator/beam/beam_bif_load.c b/erts/emulator/beam/beam_bif_load.c index 39a5bff04c..892b2d16c2 100644 --- a/erts/emulator/beam/beam_bif_load.c +++ b/erts/emulator/beam/beam_bif_load.c @@ -1013,7 +1013,7 @@ any_heap_refs(Eterm* start, Eterm* end, char* mod_start, Uint mod_size) static void copy_literals_commit(void*); #endif -copy_literals_t erts_clrange = {NULL, 0}; +copy_literals_t erts_clrange = {NULL, 0, THE_NON_VALUE}; /* copy literals * @@ -1033,7 +1033,6 @@ copy_literals_t erts_clrange = {NULL, 0}; BIF_RETTYPE erts_internal_copy_literals_2(BIF_ALIST_2) { - Module* modp; ErtsCodeIndex code_ix; Eterm res = am_true; @@ -1048,21 +1047,28 @@ BIF_RETTYPE erts_internal_copy_literals_2(BIF_ALIST_2) code_ix = erts_active_code_ix(); - if ((modp = erts_get_module(BIF_ARG_1, code_ix)) == NULL || !modp->old.code_hdr) { - res = am_false; - goto done; - } - if (BIF_ARG_2 == am_true) { - if (erts_clrange.ptr != NULL) { + Module* modp = erts_get_module(BIF_ARG_1, code_ix); + if (!modp || !modp->old.code_hdr) { + res = am_false; + goto done; + } + if (erts_clrange.ptr != NULL + && !(BIF_P->static_flags & ERTS_STC_FLG_SYSTEM_PROC)) { res = am_aborted; goto done; - } - erts_clrange.ptr = (Eterm*) modp->old.code_hdr->literals_start; - erts_clrange.sz = (Eterm*) modp->old.code_hdr->literals_end - erts_clrange.ptr; + } + erts_clrange.ptr = modp->old.code_hdr->literals_start; + erts_clrange.sz = modp->old.code_hdr->literals_end - erts_clrange.ptr; + erts_clrange.pid = BIF_P->common.id; } else if (BIF_ARG_2 == am_false) { + if (erts_clrange.pid != BIF_P->common.id) { + res = am_false; + goto done; + } erts_clrange.ptr = NULL; erts_clrange.sz = 0; + erts_clrange.pid = THE_NON_VALUE; } #ifdef ERTS_SMP |