JDK-4256603 : method with large number of locals causes StackOverflowError
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.3.0
  • Priority: P1
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1999-07-23
  • Updated: 1999-07-26
  • Resolved: 1999-07-26
Related Reports
Duplicate :  
Description

Name: dkC59003			Date: 07/23/99



JDK 1.3L fails the following JCK(114a, 116a, 12a) test:

	vm/instr/astore_w/astore_w004/astore_w00401/astore_w00401.html

which contains method with 65535 locals.

"The greatest number of local variables in the local variables array of a frame
created upon invocation of a method is limited to 65535 by the size of the max_locals
item of the Code attribute ($4.7.3) giving the code of the method."
(JVMS, second edition, CHAPTER 4 The class File Format, 
section 4.10 Limitations of the Java Virtual Machine)

The failure is reproduced only when hotspot VM is used.
The test is passed under -classic mode.

See reduced test case and logs below.

****************************** test.jasm source **************************

public class  test {

public static Method run:"()I"
	stack 2 locals 65535
	{

        iconst_0;
		ireturn;
	}

public static Method main:"([Ljava/lang/String;)V"
	stack 2 locals 2
	{
		aload_0;
		invokestatic	Method run:"()I";
		return;
	}

} 

****************************** do.bat source **************************
rem do.bat 
@echo off

H:\ld25\java\dest\jdk1.3L\win32\bin\java %1 -version
H:\ld25\java\dest\jdk1.3L\win32\bin\java %1 -verify test

if not errorlevel=1  goto L1
echo ----Bad----
goto end

:L1
if errorlevel=0  echo ----OK----

:end


****************************** logs ******************************
>do.bat -classic
java version "1.3"
Classic VM (build JDK-1.3-L, native threads, nojit)
----OK----
>
>
>do.bat
java version "1.3"
HotSpot Client VM (1.3beta, mixed mode, build l)
Exception in thread "main" java.lang.StackOverflowError
	at test.main(test.jasm)
----Bad----
>
****************************************************************

======================================================================

Comments
EVALUATION The stack overflow is valid. The test creates a stack frame with 64K locals, giving a stack frame size of 256K. In Kestrel, the default thread stack size was reduced from 1MB to 256K, giving the stack overflow. If the jvm.dll is installed in jdk1.2.2 the test runs fine. Note that classic VM interpreter allocated Java frames on the side and not on the native stack, explaining why the test passes under classic. steffen.grarup@eng 1999-07-25
25-07-1999