diff options
| author | John Eckersberg <jeckersb@redhat.com> | 2019-09-23 14:33:40 -0400 |
|---|---|---|
| committer | John Eckersberg <jeckersb@redhat.com> | 2019-09-23 15:14:37 -0400 |
| commit | dd36f26d434389d22ff718d55a7ddc80acae9811 (patch) | |
| tree | 642f8733bf7742f262c8f7534ec5a43844da2f9c | |
| parent | edf98f35087da9f67cea8629cce1a1130299acaf (diff) | |
| download | rabbitmq-server-git-dd36f26d434389d22ff718d55a7ddc80acae9811.tar.gz | |
rabbit_diagnostics: handle race in binary_refs
It is possible for a process to terminate between the call to
processes() and subsequent call to process_info(), and the latter
returns undefined instead of a tuple. This results in the crash:
Error: {{badmatch,undefined},
[{rabbit_diagnostics,binary_refs,1,
[{file,"src/rabbit_diagnostics.erl"},{line,98}]},
{rabbit_diagnostics,'-top_binary_refs/1-lc$^0/1-0-',1,
[{file,"src/rabbit_diagnostics.erl"},{line,93}]},
{rabbit_diagnostics,'-top_binary_refs/1-lc$^0/1-0-',1,
[{file,"src/rabbit_diagnostics.erl"},{line,93}]},
{rabbit_diagnostics,top_binary_refs,1,
[{file,"src/rabbit_diagnostics.erl"},{line,93}]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,670}]}]}
| -rw-r--r-- | src/rabbit_diagnostics.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/rabbit_diagnostics.erl b/src/rabbit_diagnostics.erl index c3f515d3e7..d05401b6bf 100644 --- a/src/rabbit_diagnostics.erl +++ b/src/rabbit_diagnostics.erl @@ -94,9 +94,12 @@ top_binary_refs(Count) -> io:format("~s ~p~n", [get_time(), Sorted]). binary_refs(Pid) -> - {binary, Refs} = info(Pid, binary, []), - lists:sum([Sz || {_Ptr, Sz} <- lists:usort([{Ptr, Sz} || - {Ptr, Sz, _Cnt} <- Refs])]). + case info(Pid, binary, []) of + {binary, Refs} -> + lists:sum([Sz || {_Ptr, Sz} <- lists:usort([{Ptr, Sz} || + {Ptr, Sz, _Cnt} <- Refs])]); + _ -> 0 + end. info(Pid) -> [{pid, Pid} | info(Pid, ?PROCESS_INFO, [])]. |
