diff options
author | Sverker Eriksson <sverker@erlang.org> | 2023-04-19 17:22:24 +0200 |
---|---|---|
committer | Sverker Eriksson <sverker@erlang.org> | 2023-04-19 17:22:24 +0200 |
commit | 413a0f59451382742702d1ff60e36c89df7eaf3e (patch) | |
tree | 04c91b8965b936ed8883bc3a461dc589f785564d /erts | |
parent | 249d283ab7eda6e5b17c27ef8f7a4d0d2c70a3af (diff) | |
parent | 6a221ba780e9388589f3cc48c78ec862af4b9ae6 (diff) | |
download | erlang-413a0f59451382742702d1ff60e36c89df7eaf3e.tar.gz |
Merge branch 'rickard/aliasmonitor-fix/25.3/OTP-18557' into maint
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/bif.c | 1 | ||||
-rw-r--r-- | erts/emulator/beam/erl_bif_unique.c | 11 | ||||
-rw-r--r-- | erts/emulator/beam/erl_proc_sig_queue.c | 1 | ||||
-rw-r--r-- | erts/emulator/test/process_SUITE.erl | 50 |
4 files changed, 57 insertions, 6 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index c4687f04b8..fe3dbb4c48 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -370,6 +370,7 @@ demonitor(Process *c_p, Eterm ref, Eterm *multip) NIL, THE_NON_VALUE); amdp->origin.flags = mon->flags & ERTS_ML_STATE_ALIAS_MASK; + mon->flags &= ~ERTS_ML_STATE_ALIAS_MASK; erts_monitor_tree_replace(&ERTS_P_MONITORS(c_p), mon, &amdp->origin); break; } diff --git a/erts/emulator/beam/erl_bif_unique.c b/erts/emulator/beam/erl_bif_unique.c index 7b3b3746b1..e1686c6f93 100644 --- a/erts/emulator/beam/erl_bif_unique.c +++ b/erts/emulator/beam/erl_bif_unique.c @@ -591,14 +591,15 @@ erts_pid_ref_delete(Eterm ref) erts_rwmtx_rwlock(&tblp->rwmtx); tep = hash_remove(&tblp->hash, &tmpl); - ASSERT(tep); erts_rwmtx_rwunlock(&tblp->rwmtx); - if (tblp != &pid_ref_table[0].u.table) - erts_free(ERTS_ALC_T_PREF_NSCHED_ENT, (void *) tep); - else - erts_free(ERTS_ALC_T_PREF_ENT, (void *) tep); + if (tep) { + if (tblp != &pid_ref_table[0].u.table) + erts_free(ERTS_ALC_T_PREF_NSCHED_ENT, (void *) tep); + else + erts_free(ERTS_ALC_T_PREF_ENT, (void *) tep); + } } } diff --git a/erts/emulator/beam/erl_proc_sig_queue.c b/erts/emulator/beam/erl_proc_sig_queue.c index d2799bdb91..79d661675e 100644 --- a/erts/emulator/beam/erl_proc_sig_queue.c +++ b/erts/emulator/beam/erl_proc_sig_queue.c @@ -5628,6 +5628,7 @@ erts_proc_sig_handle_incoming(Process *c_p, erts_aint32_t *statep, mdp->ref, c_p->common.id, NIL, NIL, THE_NON_VALUE); amdp->origin.flags = ERTS_ML_STATE_ALIAS_UNALIAS; + omon->flags &= ~ERTS_ML_STATE_ALIAS_MASK; erts_monitor_tree_replace(&ERTS_P_MONITORS(c_p), omon, &amdp->origin); diff --git a/erts/emulator/test/process_SUITE.erl b/erts/emulator/test/process_SUITE.erl index 114fa42da8..080b63c5f6 100644 --- a/erts/emulator/test/process_SUITE.erl +++ b/erts/emulator/test/process_SUITE.erl @@ -96,6 +96,8 @@ monitor_alias/1, spawn_monitor_alias/1, alias_process_exit/1, + demonitor_aliasmonitor/1, + down_aliasmonitor/1, monitor_tag/1]). -export([prio_server/2, prio_client/2, init/1, handle_event/2]). @@ -183,7 +185,8 @@ groups() -> gc_request_when_gc_disabled, gc_request_blast_when_gc_disabled, otp_16436, otp_16642]}, {alias, [], - [alias_bif, monitor_alias, spawn_monitor_alias, alias_process_exit]}]. + [alias_bif, monitor_alias, spawn_monitor_alias, alias_process_exit, + demonitor_aliasmonitor, down_aliasmonitor]}]. init_per_suite(Config) -> A0 = case application:start(sasl) of @@ -5017,6 +5020,51 @@ alias_process_exit(Config) when is_list(Config) -> check_pid_ref_table_size(PRTSz), ok. +demonitor_aliasmonitor(Config) when is_list(Config) -> + {ok, Peer, Node} = ?CT_PEER(), + Fun = fun () -> + receive + {alias, Alias} -> + Alias ! {alias_reply, Alias, self()} + end + end, + LPid = spawn(Fun), + RPid = spawn(Node, Fun), + AliasMonitor = erlang:monitor(process, LPid, [{alias, explicit_unalias}]), + erlang:demonitor(AliasMonitor), + LPid ! {alias, AliasMonitor}, + receive {alias_reply, AliasMonitor, LPid} -> ok end, + %% Demonitor signal has been received and cleaned up. Cleanup of + %% it erroneously removed it from the alias table which caused + %% remote use of the alias to stop working... + RPid ! {alias, AliasMonitor}, + receive {alias_reply, AliasMonitor, RPid} -> ok end, + exit(LPid, kill), + peer:stop(Peer), + false = is_process_alive(LPid), + ok. + +down_aliasmonitor(Config) when is_list(Config) -> + {ok, Peer, Node} = ?CT_PEER(), + LPid = spawn(fun () -> receive infinty -> ok end end), + RPid = spawn(Node, + fun () -> + receive + {alias, Alias} -> + Alias ! {alias_reply, Alias, self()} + end + end), + AliasMonitor = erlang:monitor(process, LPid, [{alias, explicit_unalias}]), + exit(LPid, bye), + receive {'DOWN', AliasMonitor, process, LPid, bye} -> ok end, + %% Down signal has been received and cleaned up. Cleanup of + %% it erroneously removed it from the alias table which caused + %% remote use of the alias to stop working... + RPid ! {alias, AliasMonitor}, + receive {alias_reply, AliasMonitor, RPid} -> ok end, + peer:stop(Peer), + ok. + monitor_tag(Config) when is_list(Config) -> %% Exit signals with immediate exit reasons are sent %% in a different manner than compound exit reasons, and |