File 0851-fix-param-ordering-of-gen_event-crash.patch of Package erlang
From f408cd265624e316af84aa768e122cfc725be766 Mon Sep 17 00:00:00 2001
From: David Buckley <davidbuckley@gambitresearch.com>
Date: Fri, 17 Dec 2021 13:53:44 +0000
Subject: [PATCH 1/2] fix param ordering of gen_event crash
Currently we get error messages like the following logged:
```
2021-11-09T09:27:03.949055+00:00 error: Generic event handler ... crashed. Installed: .... Last event: {badarg,[{ets,match_object,[...],[{error_info,#{cause => id,module => erl_stdlib_errors}}]}|...]}. State: {event,...}. Reason: {state,...}.
```
This is very confusing (caused us to go on a rabbit hunt through our own
code for transposed `State`/`Reason` in `{stop,...}` return values).
---
lib/stdlib/src/gen_event.erl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/stdlib/src/gen_event.erl b/lib/stdlib/src/gen_event.erl
index ff6e578f2f..4ac44d9b1f 100644
--- a/lib/stdlib/src/gen_event.erl
+++ b/lib/stdlib/src/gen_event.erl
@@ -897,10 +897,10 @@ format_log_single(#{label:={gen_event,terminate},
Args1 =
case Depth of
unlimited ->
- [Handler,SName,Reason1,LastIn,State];
+ [Handler,SName,LastIn,State,Reason1];
_ ->
- [Handler,Depth,SName,Depth,Reason1,Depth,
- LastIn,Depth,State,Depth]
+ [Handler,Depth,SName,Depth,LastIn,Depth,
+ State,Depth,Reason1,Depth]
end,
{Format1, Args1};
format_log_single(#{label:={gen_event,no_handle_info},
--
2.31.1