File 0906-Fix-port-crash.patch of Package erlang
From abafcba3d239241ca14c06813decc5a9527b854b Mon Sep 17 00:00:00 2001
From: Dan Gudmundsson <dgud@erlang.org>
Date: Wed, 18 Oct 2023 10:03:45 +0200
Subject: [PATCH] Fix port crash
Could crash if port had died.
Fixes #7735
---
lib/runtime_tools/src/observer_backend.erl | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/lib/runtime_tools/src/observer_backend.erl b/lib/runtime_tools/src/observer_backend.erl
index ccd2240a99..d95fdbc328 100644
--- a/lib/runtime_tools/src/observer_backend.erl
+++ b/lib/runtime_tools/src/observer_backend.erl
@@ -169,11 +169,21 @@ get_mnesia_loop(Parent, {Match, Cont}) ->
get_port_list() ->
ExtraItems = [monitors,monitored_by,parallelism,locking,queue_size,memory],
- [begin
- [{port_id,P}|erlang:port_info(P)] ++
- port_info(P,ExtraItems) ++
- inet_port_extra(erlang:port_info(P, name), P)
- end || P <- erlang:ports()].
+ PortInfo =
+ fun(P, Acc) ->
+ case erlang:port_info(P) of
+ undefined ->
+ Acc;
+ Info ->
+ [
+ [{port_id,P}|Info] ++
+ port_info(P,ExtraItems) ++
+ inet_port_extra(erlang:port_info(P, name), P)
+ | Acc ]
+ end
+ end,
+ PIs = lists:foldl(PortInfo, [], erlang:ports()),
+ lists:reverse(PIs).
port_info(P,[Item|Items]) ->
case erlang:port_info(P,Item) of
--
2.35.3