Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 72939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:07:24+00:00 2026-05-10T20:07:24+00:00

Posting a stack overflow question on stackoverflow.com, how amusing :-) I’m running some recursive

  • 0

Posting a stack overflow question on stackoverflow.com, how amusing 🙂

I’m running some recursive Ruby code and I get the: 'Stack level too deep (SystemStackError)'

(I’m quite sure the code works, that I’m not in an infinite recursive death spiral, but that is not the point anyway)

Is there anyway to change the allowed stack depth/size for my Ruby app?

I don’t quite get it if this is a restriction in Ruby, since the error says ‘Stack level’, which gives me the impression that Ruby somehow counts ‘levels’ of stack, or if it simply means that the stack is full.

I have tried running this program under both Vista and Ubuntu with same result. Under Ubuntu i tried changing the stack size with ‘ulimit -s’ from 8192 to 16000, but that didn’t change anything.

Edit: Thanks for the feedback.
I do realize that using a recursive function perhaps isn’t the most robust way to go. But that isn’t the point either. I simply wonder if there is a way to increase the stack size.. period. And as I mentioned i did try running ulimit -s 16000 before running the ruby script.. with no improvement.. Am I using it wrong?

Edit2: I was in fact having an infinite recursion in an edge case of the code.
The truncated ruby stack trace when you get the 'Stack level too deep' error is a bit misleading.
When having a recursive behavior involving several functions, you get the impression that the numbers of recursions is much lower than it actually is. In this example one might thing that it crashes after little bit more than 190 calls, but it is actually around 15000 calls

tst.rb:8:in `p': stack level too deep (SystemStackError)         from tst.rb:8:in `bar'         from tst.rb:12:in `bar'         from tst.rb:19:in `foo'         from tst.rb:10:in `bar'         from tst.rb:19:in `foo'         from tst.rb:10:in `bar'         from tst.rb:19:in `foo'         from tst.rb:10:in `bar'          ... 190 levels...         from tst.rb:19:in `foo'         from tst.rb:10:in `bar'         from tst.rb:19:in `foo'         from tst.rb:22 

-Andreas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:07:24+00:00Added an answer on May 10, 2026 at 8:07 pm

    Ruby uses the C stack so your options include using ulimit or compiling Ruby with some compiler/linker stack size flag. Tail recursion is yet to be implemented and Ruby’s current support for recursion isn’t so great. As cool and elegant recursion is, you might want to consider coping with the language’s limitations and writing your code in a different way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 117k
  • Answers 117k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Should this even be done? A alert is displayed for… May 11, 2026 at 10:44 pm
  • Editorial Team
    Editorial Team added an answer The difference here is much less than your previous question.… May 11, 2026 at 10:44 pm
  • Editorial Team
    Editorial Team added an answer It's a big problem. If I send you a link… May 11, 2026 at 10:44 pm

Related Questions

Posting a stack overflow question on stackoverflow.com, how amusing :-) I'm running some recursive
Under Linux, my C++ application is using fork() and execv() to launch multiple instances
Good morning, all. This is my first question on stackoverflow, so hopefully this isn't
This is my first time posting on Stackoverflow, but I've been reading through many
I'm working on a CRUD site with a lot of very similar forms for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.