This program quickly overflows the stack due to the unconditional recursive calls between .foo and .bar:
class A def main .foo(List<of int>()) def foo(t as List<of int>) .bar(Set<of int>()) def bar(s as Set<of int>) .foo(List<of int>())
On DotNet, a StackOverflowException will be produced, but with no stackframes. On NovellMono, the program will simply crash with some systems reporting a SIGSEGV and others displaying no additional output of any type. The behavior of the virtual machines is out of control of the Cobra project, however, the Cobra compiler can add additional code generation to track stackframes and then complain if they reach an upper limit. This is invoked with the DetailedStackTrace option like so:
$ cobra -dst stackoverflow.cobra Cobra detected stack overflow: Last 20 frames: 480. def A.foo at line 5 481. def A.bar at line 7 482. def A.foo at line 5 483. def A.bar at line 7 484. def A.foo at line 5 485. def A.bar at line 7 486. def A.foo at line 5 487. def A.bar at line 7 488. def A.foo at line 5 489. def A.bar at line 7 490. def A.foo at line 5 491. def A.bar at line 7 492. def A.foo at line 5 493. def A.bar at line 7 494. def A.foo at line 5 495. def A.bar at line 7 496. def A.foo at line 5 497. def A.bar at line 7 498. def A.foo at line 5 499. def A.bar at line 7 500. def A.foo at line 4 Fail fast: Stack Overflow Exiting with -1
There is a performance overhead, so this option is generally only used for troubleshooting.
See also: DetailedStackTrace