Issue #6216 has been updated by headius (Charles Nutter).


Some details on the JRuby side of things:

* SystemStackError is not consistently raised. There are a decreasing number of places in JRuby's codebase where we attempt to rescue Java's StackOverflowError and reraise it as SystemStackError. Largely, this is because at the point where we catch a StackOverflow, there may not be sufficient stack available to construct the Ruby exception. So you can't expect to always get SystemStackError in JRuby.

* SystemStackError is an unrecoverable error in any runtime. It can happen at very odd times, including during native bits of MRI, exception handling or ensure blocks, and so on. In general, we treat a stack overflow as a fatal error case.

* JRuby in general will just allow the Java StackOverflowError to propagate as-is. You can catch the Java exception using JRuby's Java integration, but as mentioned above stack errors are generally unrecoverable.

* The JVM (Hotspot, at least) only returns a subset of any deep stack trace, even for non-overflow cases. This is the main reason for the truncated backtrace.
----------------------------------------
Feature #6216: SystemStackError backtraces should not be reduced to one line
https://bugs.ruby-lang.org/issues/6216#change-32127

Author: postmodern (Hal Brodigan)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: next minor


When debugging "SystemStackError: stack level too deep" exceptions, it is not helpful that the backtrace is reduced to one single line. Most of the time Ruby incorrectly identifies where cycles begin, resulting in an unrelated "file:line" as the backtrace. A more useful behaviour would be to print the last 30 lines of the backtrace, and have the developer identify which "file:line" is causing the cycle. This is similar to how JRuby handles SystemStackError backtraces.


-- 
http://bugs.ruby-lang.org/