File 2785-Clean-up-handling-of-gen-exits-in-gen_statem.patch of Package erlang

From 414bf11153206d83bd37e9eacfe5e30866d6be5f Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Wed, 9 Mar 2022 12:29:30 +0100
Subject: [PATCH 5/8] Clean up handling of `gen` exits in `gen_statem`

The `gen` module raises `exit` exceptions when it
detects an error.  Clean up handling of these by
not handling other classes of errors, to not
accidentally bury an interesting cannot-happen-error.
---
 lib/stdlib/src/gen_statem.erl | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index 63b60e99e9..51ac904ee9 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -719,9 +719,11 @@ call_dirty(ServerRef, Request, Timeout, T) ->
         {ok,Reply} ->
             Reply
     catch
-        Class:Reason:Stacktrace ->
+        %% 'gen' raises 'exit' for problems
+        Class:Reason:Stacktrace when Class =:= exit ->
             erlang:raise(
               Class,
+              %% Wrap the reason according to tradition
               {Reason,{?MODULE,call,[ServerRef,Request,Timeout]}},
               Stacktrace)
     end.
@@ -763,12 +765,19 @@ call_clean(ServerRef, Request, Timeout, T) ->
                 {ok,Reply} ->
                     Reply
             end;
-        {Ref,Class,Reason,Stacktrace} ->
+        {Ref,Class,Reason,Stacktrace} when Class =:= exit ->
+            %% 'gen' raises 'exit' for problems
             demonitor(Mref, [flush]),
+            %% Pretend it happened in this process
             erlang:raise(
               Class,
+              %% Wrap the reason according to tradition
               {Reason,{?MODULE,call,[ServerRef,Request,Timeout]}},
               Stacktrace);
+        {Ref,Class,Reason,Stacktrace} ->
+            demonitor(Mref, [flush]),
+            %% Pretend it happened in this process
+            erlang:raise(Class, Reason, Stacktrace);
         {'DOWN',Mref,_,_,Reason} ->
             %% There is a theoretical possibility that the
             %% proxy process gets killed between try--of and !
-- 
2.34.1

openSUSE Build Service is sponsored by