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

SystemStackError when trying to rebuild a tree with depth of 500. #297

Open
phallstrom opened this issue Jan 16, 2018 · 3 comments
Open

Comments

@phallstrom
Copy link

If you've got a hierarchy with a depth of around 500 you can't rebuild! the tree without it resulting in a SystemStackError: stack level too deep.

Here's a test that illustrates the failure. I don't have a patch or workaround, but wanted to report it.

    it 'rebuilds deeply nested tree' do
      parent = nil
      500.times do |counter|
        parent = Metal.create(:value => "Nitro-#{counter}", parent: parent)
      end
      expect { Metal.rebuild! }.not_to raise_error
    end

@joelvh
Copy link

joelvh commented Jan 28, 2018

@phallstrom that's the Ruby limit to ensure you don't have an infinite loop.

A quick Google search to increase the Ruby stack depth reveals this post on Stack Overflow: https://stackoverflow.com/questions/242617/how-to-increase-stack-size-for-a-ruby-app-recursive-app-getting-stack-level-to

Look at RUBY_THREAD_VM_STACK_SIZE and some of the other more recent posts for Ruby 2.0+

@phallstrom
Copy link
Author

@joelvh Agreed. I should have included that. Wanted to report the issue as in case others come across it and/or want to rewrite the code so it doesn't recurse and avoid the issue entirely.

@saiqulhaq
Copy link

maybe we can write this into README.md and close this issue

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

No branches or pull requests

3 participants