Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io_lib:format/3 with chars_limit crashes on certain data #5053

Closed
aartamonau opened this issue Jul 15, 2021 · 2 comments
Closed

io_lib:format/3 with chars_limit crashes on certain data #5053

aartamonau opened this issue Jul 15, 2021 · 2 comments
Assignees
Labels
bug Issue is reported as a bug in progress team:VM Assigned to OTP team VM

Comments

@aartamonau
Copy link

Describe the bug
On certain data io_lib:format() crashes when chars_limit is used with a badarg error.

To Reproduce
Run the following snippet. The link to bucket_conf.txt: https://pastebin.com/dl/NYMGCzWU.

1> {ok, [Name, Conf]} = file:consult("bucket_conf.txt"), io_lib:format("Rebalancing bucket ~p with config ~p", [Name, Conf], [{chars_limit, 50000}]).
** exception error: bad argument
     in function  io_lib:format/2
        called as io_lib:format("Rebalancing bucket ~p with config ~p",
                                ["fW7UdP9XFESEaeyN9jyZh-P95aEjty7iOj4IOQSKlHTT0RORo4%og42zG37TitH7%-NP_51-34-501000",
                                 [{auth_type,sasl},
                                  {num_replicas,2},
                                  {replica_index,true},
                                  {ram_quota,2097152000},
                                  {durability_min_level,none},
                                  {frag_percent,50},
                                  {pitr_enabled,false},
                                  {pitr_granularity,600},
                                  {pitr_max_history_age,86400},
                                  {autocompaction,false},
                                  {purge_interval,undefined},
                                  {flush_enabled,false},
                                  {num_threads,3},
                                  {eviction_policy,full_eviction},
                                  {conflict_resolution_type,seqno},
                                  {storage_mode,magma},
                                  {max_ttl,0},
                                  {compression_mode,active},
                                  {type,membase},
                                  {num_vbuckets,1024},
                                  {replication_topology,star},
                                  {repl_type,dcp},
                                  {servers,[...]},
                                  {map_opts_hash,...},
                                  {...}|...]])

Calling io_lib_format:fwrite/3 directly produces the following crash:

2> io_lib_format:fwrite("Rebalancing bucket ~p with config ~p", [Name, Conf], [{chars_limit, 50000}]).
** exception error: no function clause matching io_lib_pretty:pp_tag_tuple({dots,3,3,#Fun<io_lib_pretty.9.27497820>},
                                                                           117,80,49889,1,
                                                                           [32,32,
                                                                            [32,
                                                                             [[[32,"   ",32,32,32],32,"   ",32,32,32],
                                                                              [32,"   ",32,32,32],
                                                                              32,"   ",32,32,32],
                                                                             [[32,"   ",32,32,32],32,"   ",32,32,32],
                                                                             [32,"   ",32,32,32],
                                                                             32,"   ",32,32,32],
                                                                            32,
                                                                            [[[32,"   ",32,32,32],32,"   ",32,32,32],
                                                                             [32,"   ",32,32,32],
                                                                             32,"   ",32,32,32],
                                                                            [[32,"   ",32,32,32],32,"   ",32,32,32],
                                                                            [32,"   ",32,32,32],
                                                                            32,"   ",32,32,32],
                                                                           1,1) (io_lib_pretty.erl, line 188)
     in function  io_lib_pretty:pp/8 (io_lib_pretty.erl, line 173)
     in call from io_lib_pretty:pp_element/8 (io_lib_pretty.erl, line 341)
     in call from io_lib_pretty:pp_tail/10 (io_lib_pretty.erl, line 323)
     in call from io_lib_pretty:pp_tail/10 (io_lib_pretty.erl, line 325)
     in call from io_lib_pretty:pp_list/9 (io_lib_pretty.erl, line 310)
     in call from io_lib_pretty:pp/8 (io_lib_pretty.erl, line 171)
     in call from io_lib_format:build_limited/5 (io_lib_format.erl, line 282)

Expected behavior
The snippet should not crash.

Affected versions
Reproducible on OTP-22 and OTP-24.

@aartamonau aartamonau added the bug Issue is reported as a bug label Jul 15, 2021
@uabboli uabboli self-assigned this Jul 15, 2021
uabboli added a commit that referenced this issue Jul 16, 2021
uabboli added a commit that referenced this issue Jul 16, 2021
* hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525:
  stdlib: Fix a concerning io_lib option 'chars_limit'
@KennethL KennethL added the team:VM Assigned to OTP team VM label Jul 19, 2021
@hareen-kancharla
Copy link

hareen-kancharla commented Jul 20, 2021

Hi, will this be merged into OTP-22 too?

IngelaAndin pushed a commit that referenced this issue Jul 22, 2021
…int-23

* hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525:
  stdlib: Fix a concerning io_lib option 'chars_limit'

# Conflicts:
#	lib/stdlib/test/io_SUITE.erl
IngelaAndin pushed a commit that referenced this issue Jul 22, 2021
…int-24

* hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525:
  stdlib: Fix a concerning io_lib option 'chars_limit'

# Conflicts:
#	lib/stdlib/test/io_SUITE.erl
@uabboli
Copy link
Contributor

uabboli commented Jul 22, 2021

Thanks for the bug report.

A fix has been merged to maint and master, and patches have been created for 23 and 24 (OTP-23.3.4.5, OTP-24.0.4). There will be a patch for 22.

@uabboli uabboli closed this as completed Jul 22, 2021
hareen-kancharla added a commit to couchbasedeps/erlang that referenced this issue Jul 23, 2021
erlang#5053

This is being temporarily committed (along with moving chars_limit back
to 50K) to get more test coverage.
bjorng pushed a commit that referenced this issue Sep 3, 2021
…int-22

* hasse/stdlib/chars_limit_fix/GH-5053/OTP-17525:
  stdlib: Fix a concerning io_lib option 'chars_limit'

# Conflicts:
#	lib/stdlib/test/io_SUITE.erl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug in progress team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

4 participants