Wiki

Changes between Initial Version and Version 1 of StackOverflow

Show
Ignore:
Timestamp:
10/25/10 08:40:30 (14 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StackOverflow

    v1 v1  
     1This program quickly overflows the stack due to the unconditional recursive calls between .foo and .bar: 
     2{{{ 
     3class A 
     4        def main 
     5                .foo(List<of int>()) 
     6        def foo(t as List<of int>) 
     7                .bar(Set<of int>()) 
     8        def bar(s as Set<of int>) 
     9                .foo(List<of int>()) 
     10}}} 
     11 
     12On Microsoft .NET, a !StackOverflowException will be produced. However, on NovellMono, the program will simply crash with some systems reporting a SIGSEGV and others displaying no additional output of any type. This behavior of the NovellMono VirtualMachine 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: 
     13 
     14{{{ 
     15$ cobra -dst stackoverflow.cobra 
     16Cobra detected stack overflow: 
     17  Last 20 frames: 
     18    480. def A.foo at line 5 
     19    481. def A.bar at line 7 
     20    482. def A.foo at line 5 
     21    483. def A.bar at line 7 
     22    484. def A.foo at line 5 
     23    485. def A.bar at line 7 
     24    486. def A.foo at line 5 
     25    487. def A.bar at line 7 
     26    488. def A.foo at line 5 
     27    489. def A.bar at line 7 
     28    490. def A.foo at line 5 
     29    491. def A.bar at line 7 
     30    492. def A.foo at line 5 
     31    493. def A.bar at line 7 
     32    494. def A.foo at line 5 
     33    495. def A.bar at line 7 
     34    496. def A.foo at line 5 
     35    497. def A.bar at line 7 
     36    498. def A.foo at line 5 
     37    499. def A.bar at line 7 
     38    500. def A.foo at line 4 
     39Fail fast: Stack Overflow 
     40Exiting with -1 
     41}}} 
     42 
     43See also: DetailedStackTrace