summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/beam_bp.c
diff options
context:
space:
mode:
authorJohn Högberg <john@erlang.org>2022-12-06 14:17:29 +0100
committerJohn Högberg <john@erlang.org>2022-12-12 14:54:20 +0100
commite444d1f9e4e782e9ff1407f61251ac79a5cf3ae5 (patch)
tree2a51b138d332529740e3d22e774229fe4b4dc5a8 /erts/emulator/beam/beam_bp.c
parentfc3295b1ebeed1235d12983184ba806f2ce2f525 (diff)
downloaderlang-e444d1f9e4e782e9ff1407f61251ac79a5cf3ae5.tar.gz
erts: Fix race in fun loading
Because funs are tied to their canonical module rather than a specific instance of a module, they are "moved over" to the newest instance whenever we reload _the exact same module_ over itself. This quirk, together with how fun entries are updated when a module is loaded, caused a small window where it was possible for a holder of an "old" fun to call the new instance before it was fully loaded. This commit fixes that by versioning funs in roughly the same way we do exports. It also fixes a related bug where fun purging could be messed up if a new module instance was loaded in the middle of purging, solving the issue by disallowing code loading while purging a module with funs.
Diffstat (limited to 'erts/emulator/beam/beam_bp.c')
-rw-r--r--erts/emulator/beam/beam_bp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/erts/emulator/beam/beam_bp.c b/erts/emulator/beam/beam_bp.c
index 023e67a96a..82bb8c5eb8 100644
--- a/erts/emulator/beam/beam_bp.c
+++ b/erts/emulator/beam/beam_bp.c
@@ -289,7 +289,7 @@ erts_consolidate_bp_data(BpFunctions* f, int local)
Uint i;
Uint n = f->matched;
- ERTS_LC_ASSERT(erts_has_code_write_permission());
+ ERTS_LC_ASSERT(erts_has_code_mod_permission());
for (i = 0; i < n; i++) {
consolidate_bp_data(fs[i].mod, fs[i].ci_rw, local);
@@ -1397,7 +1397,7 @@ set_function_break(ErtsCodeInfo *ci, Binary *match_spec, Uint break_flags,
Uint common;
ErtsBpIndex ix = erts_staging_bp_ix();
- ERTS_LC_ASSERT(erts_has_code_write_permission());
+ ERTS_LC_ASSERT(erts_has_code_mod_permission());
g = ci->u.gen_bp;
if (g == 0) {
int i;
@@ -1530,7 +1530,7 @@ clear_function_break(const ErtsCodeInfo *ci, Uint break_flags)
Uint common;
ErtsBpIndex ix = erts_staging_bp_ix();
- ERTS_LC_ASSERT(erts_has_code_write_permission());
+ ERTS_LC_ASSERT(erts_has_code_mod_permission());
if ((g = ci->u.gen_bp) == NULL) {
return 1;