You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2018/10/17 20:32:49 UTC
[couchdb] branch fix-log-to-handle-extra-args created (now ff9b6d1)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch fix-log-to-handle-extra-args
in repository https://gitbox.apache.org/repos/asf/couchdb.git.
at ff9b6d1 Do not crash couch_log application when gen_* servers send extra args
This branch includes the following new commits:
new ff9b6d1 Do not crash couch_log application when gen_* servers send extra args
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[couchdb] 01/01: Do not crash couch_log application when gen_*
servers send extra args
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch fix-log-to-handle-extra-args
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit ff9b6d1d021d8857edfd57327f4a6f7746f23ff7
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Wed Oct 17 16:24:28 2018 -0400
Do not crash couch_log application when gen_* servers send extra args
gen_server, gen_fsm and gen_statem might send extra args when terminating. This
is a recent behavior, and not handling these extra args could lead to couch_log
application crashing and taking down the whole VM with it.
---
src/couch_log/src/couch_log_formatter.erl | 12 ++++++------
src/couch_log/test/couch_log_formatter_test.erl | 10 ++++++----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/couch_log/src/couch_log_formatter.erl b/src/couch_log/src/couch_log_formatter.erl
index 5be3619..3464800 100644
--- a/src/couch_log/src/couch_log_formatter.erl
+++ b/src/couch_log/src/couch_log_formatter.erl
@@ -58,18 +58,18 @@ format(Level, Pid, Msg) ->
format({error, _GL, {Pid, "** Generic server " ++ _, Args}}) ->
%% gen_server terminate
- [Name, LastMsg, State, Reason] = Args,
+ [Name, LastMsg, State, Reason | Extra] = Args,
MsgFmt = "gen_server ~w terminated with reason: ~s~n" ++
- " last msg: ~p~n state: ~p",
- MsgArgs = [Name, format_reason(Reason), LastMsg, State],
+ " last msg: ~p~n state: ~p~n extra: ~p",
+ MsgArgs = [Name, format_reason(Reason), LastMsg, State, Extra],
format(error, Pid, MsgFmt, MsgArgs);
format({error, _GL, {Pid, "** State machine " ++ _, Args}}) ->
%% gen_fsm terminate
- [Name, LastMsg, StateName, State, Reason] = Args,
+ [Name, LastMsg, StateName, State, Reason | Extra] = Args,
MsgFmt = "gen_fsm ~w in state ~w terminated with reason: ~s~n" ++
- " last msg: ~p~n state: ~p",
- MsgArgs = [Name, StateName, format_reason(Reason), LastMsg, State],
+ " last msg: ~p~n state: ~p~n extra: ~p",
+ MsgArgs = [Name, StateName, format_reason(Reason), LastMsg, State, Extra],
format(error, Pid, MsgFmt, MsgArgs);
format({error, _GL, {Pid, "** gen_event handler" ++ _, Args}}) ->
diff --git a/src/couch_log/test/couch_log_formatter_test.erl b/src/couch_log/test/couch_log_formatter_test.erl
index a8f69b2..b660336 100644
--- a/src/couch_log/test/couch_log_formatter_test.erl
+++ b/src/couch_log/test/couch_log_formatter_test.erl
@@ -45,7 +45,7 @@ gen_server_error_test() ->
{
Pid,
"** Generic server and some stuff",
- [a_gen_server, {foo, bar}, server_state, some_reason]
+ [a_gen_server, {foo, bar}, server_state, some_reason, sad, args]
}
},
?assertMatch(
@@ -59,7 +59,8 @@ gen_server_error_test() ->
"gen_server a_gen_server terminated",
"with reason: some_reason",
"last msg: {foo,bar}",
- "state: server_state"
+ "state: server_state",
+ "extra: \\[sad,args\\]"
]).
@@ -71,7 +72,7 @@ gen_fsm_error_test() ->
{
Pid,
"** State machine did a thing",
- [a_gen_fsm, {ohai,there}, state_name, curr_state, barf]
+ [a_gen_fsm, {ohai,there}, state_name, curr_state, barf, sad, args]
}
},
?assertMatch(
@@ -85,7 +86,8 @@ gen_fsm_error_test() ->
"gen_fsm a_gen_fsm in state state_name",
"with reason: barf",
"last msg: {ohai,there}",
- "state: curr_state"
+ "state: curr_state",
+ "extra: \\[sad,args\\]"
]).