java/1373: recursion stress test causes segmentation fault

osk@hem.passagen.se osk@hem.passagen.se
Wed Dec 20 12:25:00 GMT 2000


>Number:         1373
>Category:       java
>Synopsis:       recursion stress test causes segmentation fault
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apbianco
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 20 12:19:22 PST 2000
>Closed-Date:    
>Last-Modified:  
>Originator:     Oskar Liljeblad
>Release:        unknown-1.0
>Organization:
>Environment:
gcc/gcj 2.96 20000904
>Description:
According to the Java VM specs, §3.5.2, the vm should
throw StackOverflowError or OutOfMemoryError when the
stack is full or there's no more memory for the dynamic
stack. GCJ doesn't do this.

Consider the test program below. Here's the result of
running it in some different x86 environments:

gcj (gcj -o recurse --main=recurse recurse.java)
  Segmentation fault after >40000, <50000 recursions
Blackdown JDK 1.2.2
  Segmentation fault after >40000, <50000 recursions
gcj -O2
  Never exists - infinite recursion due to tail recursion optimization
IBM JDK 1.1.8
  Never exists - infinite recursion due to tail recursion optimization
IBM JDK 1.3.0
  Never exists - infinite recursion due to tail recursion optimization
IBM JDK 1.1.8 -nojit
  StackOverflowException with very long stack trace (>9000 lines)
gij
  Segmentation fault after >2000, <3000 recursions
>How-To-Repeat:
import java.util.Vector;

public class recurse {
	public static void main(String[] args) {
		recurse(0);
	}
	public static void recurse(int level) {
		if (level < 10000) {
			if (level % 1000 == 0)
				System.out.println(level);
		} else if (level < 100000) {
			if (level % 10000 == 0)
				System.out.println(level);
		} else if (level % 100000 == 0) {
			System.out.println(level);
		}
		recurse(level+1);
	}
}
>Fix:

>Release-Note:
>Audit-Trail:

Formerly PR gcj/345

>Unformatted:



More information about the Gcc-prs mailing list