File 0501-erts-Fix-exit_dist_fragments-test.patch of Package erlang

From df31dfdaeff91f399e5b7e378a2cb10ba191d9d4 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 21 Sep 2022 12:20:45 +0200
Subject: [PATCH 1/5] erts: Fix exit_dist_fragments test

The gather_exited function worked incorrectly and could
linger after the test case failed interfering with other
test cases. So we link to it to make sure that it exits
and fix the spawned/out_exited accounting.
---
 erts/emulator/test/distribution_SUITE.erl | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/erts/emulator/test/distribution_SUITE.erl b/erts/emulator/test/distribution_SUITE.erl
index 4acbb276aa..d57942d138 100644
--- a/erts/emulator/test/distribution_SUITE.erl
+++ b/erts/emulator/test/distribution_SUITE.erl
@@ -2767,6 +2767,7 @@ exit_dist_fragments(_Config) ->
                                    end)([])
                           end),
         {Tracer, Mref} = spawn_monitor(fun gather_exited/0),
+        link(Tracer), %% Make sure Tracer dies if we die
         erlang:trace(self(), true, [{tracer, Tracer}, set_on_spawn, procs, exiting]),
         exit_suspend(Node),
         receive
@@ -2805,15 +2806,17 @@ gather_exited() ->
 gather_exited(Pids) ->
     receive
         {trace,Pid,spawned,_,_} ->
-            gather_exited(Pids#{ Pid => true });
-        {trace,Pid,exited_out,_,_} ->
+            gather_exited(maps:update_with(spawned, fun(V) -> V + 1 end, 0, Pids#{ Pid => true }));
+        {trace,Pid,out_exited,_} ->
             {true, NewPids} = maps:take(Pid, Pids),
-            gather_exited(NewPids);
-        _M ->
-            gather_exited(Pids)
+            gather_exited(maps:update_with(out_exited, fun(V) -> V + 1 end, 0, NewPids));
+        Trace ->
+            gather_exited(maps:update_with(element(3, Trace), fun(V) -> V + 1 end, 0, Pids))
     after 1000 ->
-            if Pids == #{} -> ok;
-               true -> exit(Pids)
+            MissingPids = maps:size(maps:filter(fun(Key,_) -> not erlang:is_atom(Key) end, Pids)),
+            if MissingPids =:= 0 -> ok;
+               true -> exit({[{Pid,erlang:process_info(Pid)} || Pid <- MissingPids],
+                             maps:filter(fun(Key,_) -> erlang:is_atom(Key) end, Pids)})
             end
     end.
 
-- 
2.35.3

openSUSE Build Service is sponsored by