From 112b7d7a1946f6b90b3497ef4c176c6d066571e2 Mon Sep 17 00:00:00 2001 From: Daniil Fedotov Date: Fri, 16 Jun 2017 17:41:59 +0100 Subject: Support arbitrary crash report in proc_lib. The `error_logger_format_depth` variable is `unlimited` by default. This can cause errors when logging crash reports using sasl logger, because `io_lib:format("~P"...` does not support `unlimited` as a depth parameter. Use formatter string "~p" for unlimited depth. A way to reproduce the error: Start erl with sasl logger: erl -boot start_sasl -sasl errlog_type error -sasl sasl_error_logger tty Report arbitrary error: error_logger:error_report(crash_report, [fake_crash_report, foo]). --- lib/stdlib/src/proc_lib.erl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/stdlib/src') diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index 9ce8e7d60e..a00221fa6a 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -784,6 +784,8 @@ format_link_report([], _, _) -> format_report(Rep, Indent, Extra) when is_list(Rep) -> format_rep(Rep, Indent, Extra); +format_report(Rep, Indent, {Enc,unlimited}) -> + io_lib:format("~s~"++modifier(Enc)++"p~n", [Indent, Rep]); format_report(Rep, Indent, {Enc,Depth}) -> io_lib:format("~s~"++modifier(Enc)++"P~n", [Indent, Rep, Depth]). -- cgit v1.2.3 From 927cbc203e9339f76f18601cd855cabc6b2c8ebb Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 21 Jun 2017 15:11:00 +0200 Subject: stdlib: Fix bug in proc_lib Add a few more tests to the proc_lib_SUITE. --- lib/stdlib/src/proc_lib.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/stdlib/src') diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index a00221fa6a..d4d1bdccec 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -779,8 +779,8 @@ format_link_report([Link|Reps], Indent, Extra) -> LinkIndent = [" ",Indent], [Indent,"neighbour:\n",format_report(Rep, LinkIndent, Extra)| format_link_report(Reps, Indent, Extra)]; -format_link_report([], _, _) -> - []. +format_link_report(Rep, Indent, Extra) -> + format_report(Rep, Indent, Extra). format_report(Rep, Indent, Extra) when is_list(Rep) -> format_rep(Rep, Indent, Extra); -- cgit v1.2.3 From 986b720d85d5cabf4c8f68a5112bdeeb225c147b Mon Sep 17 00:00:00 2001 From: Dan Gudmundsson Date: Mon, 26 Jun 2017 10:34:51 +0200 Subject: Fix old length usage in string Do not invoke the internal string:lenght/1 function when the list length is wanted. Fixes backwards compatibility for old string functions. --- lib/stdlib/src/string.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/stdlib/src') diff --git a/lib/stdlib/src/string.erl b/lib/stdlib/src/string.erl index 6f7009b5d9..4972da297d 100644 --- a/lib/stdlib/src/string.erl +++ b/lib/stdlib/src/string.erl @@ -384,7 +384,7 @@ to_float(String) -> end. to_number(String, Number, Rest, List, _Tail) when is_binary(String) -> - BSz = length(List)-length(Rest), + BSz = erlang:length(List)-erlang:length(Rest), <<_:BSz/binary, Cont/binary>> = String, {Number, Cont}; to_number(_, Number, Rest, _, Tail) -> @@ -1344,7 +1344,7 @@ bin_search_str(Bin0, Start, Cont, [CP|_]=SearchCPs) -> String :: string(), Length :: non_neg_integer(). -len(S) -> length(S). +len(S) -> erlang:length(S). %% equal(String1, String2) %% Test if 2 strings are equal. @@ -1689,7 +1689,7 @@ left(String, Len) when is_integer(Len) -> left(String, Len, $\s). Character :: char(). left(String, Len, Char) when is_integer(Char) -> - Slen = length(String), + Slen = erlang:length(String), if Slen > Len -> substr(String, 1, Len); Slen < Len -> l_pad(String, Len-Slen, Char); @@ -1714,7 +1714,7 @@ right(String, Len) when is_integer(Len) -> right(String, Len, $\s). Character :: char(). right(String, Len, Char) when is_integer(Char) -> - Slen = length(String), + Slen = erlang:length(String), if Slen > Len -> substr(String, Slen-Len+1); Slen < Len -> r_pad(String, Len-Slen, Char); @@ -1741,7 +1741,7 @@ centre(String, Len) when is_integer(Len) -> centre(String, Len, $\s). centre(String, 0, Char) when is_list(String), is_integer(Char) -> []; % Strange cases to centre string centre(String, Len, Char) when is_integer(Char) -> - Slen = length(String), + Slen = erlang:length(String), if Slen > Len -> substr(String, (Slen-Len) div 2 + 1, Len); Slen < Len -> -- cgit v1.2.3