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

test failure on HP-PARISC: Rack::Utils#test_0013_raise an exception if the params are too deep: #1640

Closed
DerDakon opened this issue Apr 25, 2020 · 8 comments · Fixed by #1686

Comments

@DerDakon
Copy link

Test output:

Error:
Rack::Utils#test_0013_raise an exception if the params are too deep:
SystemStackError: stack level too deep
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `each'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `to_h'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:205:in `block in to_h'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `each'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `to_h'
[…]
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:205:in `block in to_h'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `each'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:199:in `to_h'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/query_parser.rb:76:in `parse_nested_query'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/lib/rack/utils.rb:103:in `parse_nested_query'
    /var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/test/spec_utils.rb:129:in `block (2 levels) in <top (required)>'


rails test var/tmp/portage/dev-ruby/rack-2.1.1/work/ruby25/rack-2.1.1/test/spec_utils.rb:122

Common pitfall: the stack on HPPA machines grows upwards. This one is Gentoo Linux

@leahneukirchen
Copy link
Member

Apparently the stack on HPPA is not enough to do 100 recursion levels.

  1. Perhaps something like 16 is a better default?
  2. QueryParser#parse_nested_query should catch SystemStackError

@DerDakon
Copy link
Author

The size is not unusual, I never had problems with it. Usually it's the direction that causes issues as getting the bottom of the stack is constant and always returns the first address of the stack, but not the current one.

@leahneukirchen
Copy link
Member

Well, the stack order is a Ruby issue, not a Rack problem.
Which version of Ruby is that?

I don't see benefit in allowing 100 times nested query parameters.

Can you run ruby -e 'def r(n); p n; r(n+1); end; r 1' and show how big it gets?
Does it get more when you export RUBY_THREAD_VM_STACK_SIZE=1000000?

The output of ulimit -s would be interesting too.

@DerDakon
Copy link
Author

Without: 11911
With: 22803
ulimit -s: 8192

@leahneukirchen
Copy link
Member

Weird, here on x86_64 I get 10918 but it runs that test fine.

@mikegee
Copy link
Contributor

mikegee commented Apr 29, 2020

@DerDakon did you elide many lines of duplicated output with […] in the original post here, or did ruby do that? If you did, how many lines where there? (around 100 or over 10,000)

@DerDakon
Copy link
Author

The first 'each' is in line 41, the 'parse_nested_query' is in line 166 of the log.

@jeremyevans
Copy link
Contributor

This should be easy to work around on HA-PARISC by setting:

Rack::Utils.default_query_parser = QueryParser.make_default(65536, 16)

While I agree that 16 levels "ought to be enough for anybody", I guess we should consider cases larger than that. Maybe 32 levels? I'll submit a PR for that.

jeremyevans added a commit to jeremyevans/rack that referenced this issue Jul 13, 2020
Should hopefully fix stack issues on HA PARISC.  32 levels ought to
be enough for anybody.

Fixes rack#1640.
jeremyevans added a commit to jeremyevans/rack that referenced this issue Jul 19, 2020
Fixes stack issues on HP-PARISC.  32 levels ought to be enough for
anybody.

Fixes rack#1640.
jeremyevans added a commit that referenced this issue Jul 19, 2020
Fixes stack issues on HP-PARISC.  32 levels ought to be enough for
anybody.

Fixes #1640.
thesamesam added a commit to thesamesam/ruby that referenced this issue Apr 7, 2023
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, Ruby's test suite passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
thesamesam added a commit to thesamesam/ruby that referenced this issue Apr 7, 2023
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, Ruby's test suite passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
thesamesam added a commit to thesamesam/ruby that referenced this issue Apr 7, 2023
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, Ruby's test suite passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
thesamesam added a commit to thesamesam/ruby that referenced this issue Apr 7, 2023
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, most of Ruby's test suite now passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
Signed-off-by: Sam James <sam@gentoo.org>
thesamesam added a commit to thesamesam/ruby that referenced this issue Apr 9, 2023
On HPPA, test_insns.rb fails (along with various Ruby gems) with
'stack level too deep (SystemStackError)'. This turns out to be because HPPA
defaults to a small(er) stack.

With this change, most of Ruby's test suite now passes on HPPA.

Thanks to both Dave and Helge for the investigation and coming up with the
patch.

Bug: https://bugs.gentoo.org/701494
Bug: https://bugs.debian.org/881773
Bug: https://bugs.debian.org/881772 (for PPC64)
Bug: rack/rack#1640
Thanks-to: John David Anglin <dave.anglin@bell.net>
Thanks-to: Helge Deller <deller@gmx.de>
Signed-off-by: Sam James <sam@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants