karupanerura / TOML-Parser

simple toml parser
Other
15 stars 6 forks source link

"Deep recursion on subroutine" warning on long files. #15

Closed bhmevik closed 7 years ago

bhmevik commented 7 years ago

When using TOML::Parser on files with a lot of entries, I get Deep recursion on subroutine "TOML::Parser::_parse_tokens" at /cluster/lib/perl5/TOML/Parser.pm line 117. Deep recursion on subroutine "TOML::Parser::_parse_token" at /cluster/lib/perl5/TOML/Parser.pm line 58. Deep recursion on subroutine "TOML::Parser::_parse_token" at /cluster/lib/perl5/TOML/Parser.pm line 58. Deep recursion on subroutine "TOML::Parser::_parse_table" at /cluster/lib/perl5/TOML/Parser.pm line 69.

I tested this with TOML::Parser 0.90 and a file with the following structure:

[user1] projects = ["proj1"] [user2] projects = ["proj2" ] [user3] [projects = ["proj1", "proj3"] etc.

As soon as I get up to 99 users, I get the first two warnings shown above. If I increase the number of users, eventually I get the remaining warnings.

Looking at TOML/Parser.pm, it seems evident that this warning is due to the recursive nature of the parsing, combined with a long input file.

Would it be possible to add no warnings 'recursion'; in Parser.pm (see, e.g., http://www.perlmonks.org/?node_id=238938), or at least create a config option for turning off the warnings? (I've tested it and it seems to work fine.)

karupanerura commented 7 years ago

@bhmevik thank you for reporting. Your description is very helpful. Thank you! This issue is fixed at https://github.com/karupanerura/TOML-Parser/commit/62c0e976d16829a94de2280d048ae03a0c7b5849. And released it as TOML::Parser@0.90_01. Please try it by cpanm TOML::Parser@0.90_01. If there are no other problem, I'll release it as 0.91 in near days.

bhmevik commented 7 years ago

I've tested it now, and it works fine. Thanks for the quick fix!