title: Ruby stack level too deep exception NOT from recursive infinite loop
body: <p><strong>EDIT : (SOLVED) actually it probably was raised BECAUSE OF an infinite loop</strong></p>
  
  <p>I was coding and after adding a method I got this :</p>
  
  <pre><code>user_name@the_computer:/media/ECC3-C3B0/Prog/mts/src/mts$ rake test --trace
  ** Invoke test (first_time)
  ** Execute test
  /home/user_name/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: stack level too deep (SystemStackError)
  rake aborted!
  Command failed with status (1): [/home/user_name/.rvm/rubies/ruby-1.9.3-p19...]
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils.rb:82:in `ruby'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/testtask.rb:99:in `block (2 levels) in define'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:60:in `verbose'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/testtask.rb:98:in `block in define'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
  /home/user_name/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `&lt;top (required)&gt;'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `load'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194@global/bin/rake:19:in `&lt;main&gt;'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
  /home/user_name/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `&lt;main&gt;'
  Tasks: TOP =&gt; test
  </code></pre>
  
  <p>I'm pretty sure there is no infinite recursive loop involved.</p>
  
  <p>The code is for now somehow gemified, but I also got the error running the ruby file directly.</p>
  
  <p>Thank you for any help on how to (get some information to, run some tests to) fix the problem, if possible without having to rewrite the whole thing...</p>
  
  <h1>Environment :</h1>
  
  <ul>
  <li>ruby 1.9.3p194 / rails 3.2.8, installed via rvm</li>
  <li>the program at this stage only uses rails string inflexions functions</li>
  <li>OS : linux kubuntu i386</li>
  <li>memory 4GO</li>
  <li>'ulimit -s' : 8192 (stack size in kB)</li>
  </ul>
  
  <h1>What I tried unsuccessfully :</h1>
  
  <ul>
  <li>removed the chunk of code where the exception was initially raised, but it was still raised a tiny bit later at runtime</li>
  <li>set stack size with command line 'ulimit -s 20000', 'ulimit -s unlimited'. Same error, apparently at the same place (which makes me think the stack size wasn't actually changed)</li>
  <li>downgraded to ruby1.9.2 / rails3.1.3, got the same message</li>
  <li>same error under Windows</li>
  </ul>
  
  <h1>Application context :</h1>
  
  <p>I'm writing an application that heavily uses ruby mixins.</p>
  
  <p>Besides I created a bunch of classes that generate mixins (instance / class methods modules to be included by other classes).</p>
  
  <p>So all in all I end up with quite a bit of generated named modules with some custom generated code, and classes with many ancestors.</p>
  
  <p>But that should eventually save me quite a bit of pain in the as$ when I write the program that sits on top of this lib (that's the plan anyway).</p>
  
  <h1>Resources I used : </h1>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/242617/how-to-increase-stack-size-for-a-ruby-app-recursive-app-getting-stack-level-to"><a href="https://stackoverflow.com/questions/242617/how-to-increase-stack-size-for-a-ruby-app-recursive-app-getting-stack-level-to">How to increase stack size for a ruby app. Recursive app getting: Stack level too deep (SystemStackError)</a></a></li>
  <li><a href="http://dalibornasevic.com/posts/5-ruby-stack-level-too-deep-systemstackerror" rel="nofollow noreferrer"><a href="http://dalibornasevic.com/posts/5-ruby-stack-level-too-deep-systemstackerror" rel="nofollow noreferrer">http://dalibornasevic.com/posts/5-ruby-stack-level-too-deep-systemstackerror</a></a></li>
  </ul>
  
  <p><strong>EDIT : Until some code is available for the showing/testing, let's abstract my question down to this one : Are there other cases that raise stack level too deep exception, besides the classical program-execution-tree-is-too-deep scenario (crossing fingers it's clear and means something...) ?</strong></p>