[erlang-bugs] Unexpected badarg from io:format

Hans Bolinder hans.bolinder@REDACTED
Thu Feb 22 14:28:23 CET 2007


[Denis Bilenko:]
> I've run into a problem with io:format, it exits with these arguments:
> 
> (emacs@REDACTED)190> io:format("~w~p", ["xxxxxxxxxxxxxxxxxxx", <<1>>]).
> ** exited: {badarg,[{io,format,
>                         [<0.27.0>,"~w~p",["xxxxxxxxxxxxxxxxxxx",<<1>>]]},
>                     {erl_eval,do_apply,5},
>                     {shell,exprs,6},
>                     {shell,eval_loop,3}]} **
> 
> Contents of string doesn't matter, but length does.

Thanks for the bug report.

The following patch should solve the problem.

Best regards,

Hans Bolinder, Erlang/OTP

*** /usr/local/otp/releases/otp_beam_solaris8_r11b_patched/lib/stdlib-1.14.3/src/io_lib_pretty.erl	Tue Jan 30 13:55:48 2007
--- io_lib_pretty.erl	Thu Feb 22 13:55:27 2007
***************
*** 159,165 ****
  %% Reuse the list created by io_lib:write_binary()...
  pp_binary([LT,LT,S,GT,GT], Col, Ll, Ind, LD) ->
      N = max(8, Ll - Col - LD),
!     [LT,LT,pp_binary(S, N, N, Ind),GT,GT].
  
  pp_binary([BS, $, | S], N, N0, Ind) ->
      Len = length(BS) + 1,
--- 159,167 ----
  %% Reuse the list created by io_lib:write_binary()...
  pp_binary([LT,LT,S,GT,GT], Col, Ll, Ind, LD) ->
      N = max(8, Ll - Col - LD),
!     [LT,LT,pp_binary(S, N, N, Ind),GT,GT];
! pp_binary(S, _Col, _Ll, _Ind, _LD) ->
!     S.
  
  pp_binary([BS, $, | S], N, N0, Ind) ->
      Len = length(BS) + 1,



More information about the erlang-bugs mailing list