X Tutup
The Wayback Machine - https://web.archive.org/web/20200906104827/https://github.com/ClosureTree/closure_tree/issues/297
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

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

phallstrom opened this issue Jan 16, 2018 · 3 comments

Comments

@phallstrom
Copy link

@phallstrom phallstrom commented Jan 16, 2018

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 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

@phallstrom phallstrom commented Jan 29, 2018

@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

@saiqulhaq saiqulhaq commented Apr 16, 2018

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.
X Tutup