JDK-4732557 : StackOverFlow can not be caught as an exception(segmentation fault occurs)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_7
  • CPU: x86
  • Submitted: 2002-08-16
  • Updated: 2002-10-16
  • Resolved: 2002-10-16
Related Reports
Relates :  
Description
 Jvm with some options can not catche stackOverFlow as an exception.
 In some cases, JVM terminates with Segmantation fault , 
 or in other cases, the behavior seems to be infinite loop.

 1. Reproduce
 
   1) Compile the attached program
   2) Invoke java command with some options
     ex.
        java -server StackTest24 10000
   
 2. Results
   
  Command line is 
     java [option] StackTest24 10000
   
  2.1 Solaris
       
    options       -Xint      default      -server
  -------------+----------+------------+-----------
   1.3.1_04    |  NG1     |   NG1      |     NG1
  -------------+----------+------------+-----------
   1.4.0_01       NG2         O.K           NG2
  -------------+----------+------------+-----------
   1.4.1rc-b19    NG2         O.K           NG2
  -------------------------------------------------
   NG1 : Hotspot runtime Error
   NG2 : Segmentation fault occurs
   O.K : StackOverflow is caught by try-catch block
   

 FYI: Linux(Turbo linux 7.0(Japanese))

    options       -Xint      default      -server
  -------------+----------+------------+-----------
   1.4.0 (fcs)    loop        loop         loop
  -------------+----------+------------+-----------
   1.4.1rc-b19    loop        loop         loop
  -------------------------------------------------
    loop : looks infinite loop ?, program does not end up.
    
  The above result can be seen by 
       "java [option] StackTest24 100000"
                                  ^^^^^^^
  With 10000, it does not happen.


 3. Configration
 
goedel[11]% uname -a            
SunOS goedel 5.7 Generic_106541-15 sun4u sparc SUNW,Ultra-60
goedel[12]% psrinfo -v
Status of processor 0 as of: 08/14/02 16:58:31
  Processor has been on-line since 08/05/02 15:23:41.
  The sparcv9 processor operates at 296 MHz,
        and has a sparcv9 floating point processor.


4. Note

  - Attachement
      StackTest24.java : Test program
      hs_err_pid28400.log : log file in 1.3.1_04 on Solaris

  - Setting the option -Xss8m, but it did not suppress the 
    segmentations falt.


2002-08-16
==============================================================================

Comments
EVALUATION Test setup in Bugs/4732557 Appears to be a problem with interpreter/runtime detection of stack overflow. The frames on stack when problem occurs are as follows (first is top of stack): [1] JVM_handle_solaris_signal(0xb, 0xffb76478, 0xffb761c0, 0x1, 0x0, 0x0), at 0xfe1af8a4 0xfe1af894: JVM_handle_solaris_signal : save %sp, -0xb0, %sp 0xfe1af898: JVM_handle_solaris_signal+0x0004: call JVM_handle_solaris_signal+0xc 0xfe1af89c: JVM_handle_solaris_signal+0x0008: sethi %hi(0x1f6000), %g4 0xfe1af8a0: JVM_handle_solaris_signal+0x000c: sethi %hi(0x7000), %g2 0xfe1af8a4: JVM_handle_solaris_signal+0x0010: st %i3, [%sp + 0x60] // non-recoverable crash $sp = 0xffb75f78 [2] __sighndlr(0xb, 0xffb76478, 0xffb761c0, 0xfe1ac35c, 0x287b4, 0x287a4), at 0xff36b830 $sp 0xffb76028: 0xffb76110 [3] sigacthandler(0xb, 0x28710, 0x0, 0x0, 0x0, 0xff37e000), at 0xff368508 $sp 0xffb76088: 0x00000000 ---- called from signal handler with signal 11 (SIGSEGV) ------ [4] 0xfa00a5c0(0xffb765ec, 0xd61, 0x0, 0x2000, 0x0, 0xfa009c84), at 0xfa00a5bf // see generate_asm_interpreter_entry 0xfa00a5bc: sethi %hi(0xffffe000), %g3 // -8192 0xfa00a5c0: st %g0, [%sp + %g3] $sp 0xffb764f8: 0xffb7655c [5] 0xfa005b64(0xffb7667c, 0xd60, 0x0, 0xfa0165f8, 0x4, 0xffb76580), at 0xfa005b63 // see generate_return_entry_for 0xfa005b64: jmp %g3 $sp 0xffb76578: 0xffb765e8 [6] 0xfa005b64(0xffb7670c, 0xd5f, 0x0, 0xfa0165f8, 0x4, 0xffb76610), at 0xfa005b63 // see generate_return_entry_for $sp 0xffb76608: 0xffb76678 ... ... repeated frames ... [3431] 0xfa005b64: jmp %g3 [3432] 0xfa000114: jmpl %i4, %o7 [3433] 0xfe03b43c: call_helper+0x0310: jmpl %o7, %o7 [3434] 0xfe04ba5c: jni_invoke_static+0x0278: call _PROCEDURE_LINKAGE_TABLE_+0x6744 [PLT] [3435] 0xfe05caa4: jni_CallStaticVoidMethod+0x012c: call jni_invoke_static [3436] 0x0001237c: main+0x13a4: jmpl %l0, %o7 Observed crash mechanism is as follows: Many interpreter frames on stack; topmost touches stack to check for guard pages; generates a stack overflow, SIGSEGV; the signal handler hits guard pages when trying to use its own frame. Problem appears to be that some recursive code done in the interpreter consumes stack space. When the interpreter_entry code finally checks for guard pages, there isn't enough stack space left to run the signal handler code. ###@###.### 2002-08-19 ----- Added an additional stack bang to asm_interpreter_entry and interpreter's native entry but it did not help. interpreter_entry's first stack bang still causes first SEGV and there isn't enough space to put the signal handler frames on stack, less than 1444 bytes to the guard pages. Reproduced with -Xcomp and the following failed compiles look suspicious, but they do not get deoptimized when run with -Xbatch. 400 b StackTest24::new_nest_vec (43 bytes) 401 !b StackTest24::recurse (38 bytes) 404 b java.util.AbstractList::hashCode (46 bytes) 405 b java.util.AbstractList::iterator (10 bytes) COMPILE FAILED However, AbstractList::hashCode and AbstractList::iterator do not get compiled in normal server runs. Test passes with the following command-line: $JAVA_HOME/bin/java -optimized -Xbatch -XX:+PrintCompilation -XX:CompileThreshold=3000 StackTest24 10000 Additional support for this being an interpreter method invocation problem. ###@###.### 2002-08-23 ----- ###@###.### 2002-09-03 Generated a simpler test code called StackTest25 (in this bug directory) This demonstrates that the problem arises from the interpreter/runtime. A Stack Overflow Error generated by stack banging at a call is delivered to the callee's stack frame. If the callee has a handler for stack overflow, this results in increasing the number of frames on the stack (undesired in the context of a stack overflow error.) Eventual result is that there isn't enough space to put JVM_handle_solaris_signal on the stack. Compiled from StackTest25.java public class StackTest25 extends java.lang.Object { static int depth; public StackTest25(); /* Stack=1, Locals=1, Args_size=1 */ public static void main(java.lang.String[]) throws java.lang.Exception; /* Stack=2, Locals=2, Args_size=1 */ public static void recurse_and_throw(int) throws java.lang.Exception; /* Stack=1, Locals=1, Args_size=1 */ public static void recurse_and_fail(int) throws java.lang.Exception; /* Stack=2, Locals=2, Args_size=1 */ static {}; /* Stack=1, Locals=0, Args_size=0 */ } Method StackTest25() 0 aload_0 1 invokespecial #1 <Method java.lang.Object()> 4 return Method void main(java.lang.String[]) 0 aload_0 1 iconst_0 2 aaload 3 invokestatic #2 <Method int parseInt(java.lang.String)> 6 putstatic #3 <Field int depth> 9 iconst_0 10 invokestatic #4 <Method void recurse_and_fail(int)> 13 goto 28 16 astore_1 17 getstatic #6 <Field java.io.PrintStream out> 20 ldc #7 <String "exception"> 22 invokevirtual #8 <Method void println(java.lang.String)> 25 goto 28 28 return Exception table: from to target type 9 13 16 <Class java.lang.StackOverflowError> Method void recurse_and_throw(int) 0 iload_0 1 invokestatic #9 <Method void recurse_and_throw(int)> 4 return Method void recurse_and_fail(int) 0 iload_0 1 invokestatic #9 <Method void recurse_and_throw(int)> 4 goto 17 7 astore_1 8 iload_0 9 iconst_1 10 iadd 11 invokestatic #4 <Method void recurse_and_fail(int)> 14 goto 17 17 return Exception table: from to target type 0 4 7 <Class java.lang.StackOverflowError> // From -Xss64k -XX:+TraceBytecodes // Modified BytecodeTracer to output address of local 'C' variable to see $SP approx yellow thread BCI stack guard BC-counter ByteCode ptr enabled? [1] static void StackTest25.recurse_and_throw(jint) 0xffbfa0cc 01 [1] 1174809 0 iload_0 0xffbfa0cc 01 [1] 1174810 1 invokestatic 6 0xffbfa054 01 [1] 1174811 0 iload_0 0xffbfa054 01 [1] 1174812 1 invokestatic 6 0xffbf9fdc 01 [1] 1174813 0 iload_0 0xffbf9fdc 01 [1] 1174814 1 invokestatic 6 0xffbf9f64 01 [1] 1174815 0 iload_0 0xffbf9f64 01 [1] 1174816 1 invokestatic 6 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869908) thrown in interpreter method <{method} 'recurse_and_fail' Bug'(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 [1] static void StackTest25.recurse_and_fail(jint) 0xffbfa144 01 [1] 1174817 7 astore_1 0xffbfa144 01 [1] 1174818 8 iload_0 0xffbfa144 01 [1] 1174819 9 iconst_1 0xffbfa144 01 [1] 1174820 10 iadd 0xffbfa144 01 [1] 1174821 11 invokestatic 3 0xffbfa0bc 01 [1] 1174822 0 iload_0 0xffbfa0bc 01 [1] 1174823 1 invokestatic 6 [1] static void StackTest25.recurse_and_throw(jint) 0xffbfa044 01 [1] 1174824 0 iload_0 0xffbfa044 01 [1] 1174825 1 invokestatic 6 0xffbf9fcc 01 [1] 1174826 0 iload_0 0xffbf9fcc 01 [1] 1174827 1 invokestatic 6 0xffbf9f54 01 [1] 1174828 0 iload_0 0xffbf9f54 01 [1] 1174829 1 invokestatic 6 Exception <a 'java/lang/StackOverflowError'> (0xf2869df8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869df8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869df8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869df8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf2869df8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 [1] static void StackTest25.recurse_and_fail(jint) 0xffbfa0bc 01 [1] 1174830 7 astore_1 0xffbfa0bc 01 [1] 1174831 8 iload_0 0xffbfa0bc 01 [1] 1174832 9 iconst_1 0xffbfa0bc 01 [1] 1174833 10 iadd 0xffbfa0bc 01 [1] 1174834 11 invokestatic 3 0xffbfa034 01 [1] 1174835 0 iload_0 0xffbfa034 01 [1] 1174836 1 invokestatic 6 [1] static void StackTest25.recurse_and_throw(jint) 0xffbf9fbc 01 [1] 1174837 0 iload_0 0xffbf9fbc 01 [1] 1174838 1 invokestatic 6 0xffbf9f44 01 [1] 1174839 0 iload_0 0xffbf9f44 01 [1] 1174840 1 invokestatic 6 Exception <a 'java/lang/StackOverflowError'> (0xf286a2e8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf286a2e8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf286a2e8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf286a2e8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 [1] static void StackTest25.recurse_and_fail(jint) 0xffbfa034 01 [1] 1174841 7 astore_1 0xffbfa034 01 [1] 1174842 8 iload_0 0xffbfa034 01 [1] 1174843 9 iconst_1 0xffbfa034 01 [1] 1174844 10 iadd 0xffbfa034 01 [1] 1174845 11 invokestatic 3 0xffbf9fac 01 [1] 1174846 0 iload_0 0xffbf9fac 01 [1] 1174847 1 invokestatic 6 [1] static void StackTest25.recurse_and_throw(jint) 0xffbf9f34 01 [1] 1174848 0 iload_0 0xffbf9f34 01 [1] 1174849 1 invokestatic 6 Exception <a 'java/lang/StackOverflowError'> (0xf286a7d8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf286a7d8) thrown in interpreter method <{method} 'recurse_and_throw' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 Exception <a 'java/lang/StackOverflowError'> (0xf286a7d8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 1 for thread 0x0003c1a8 [1] static void StackTest25.recurse_and_fail(jint) 0xffbf9fac 01 [1] 1174850 7 astore_1 0xffbf9fac 01 [1] 1174851 8 iload_0 0xffbf9fac 01 [1] 1174852 9 iconst_1 0xffbf9fac 01 [1] 1174853 10 iadd 0xffbf9fac 01 [1] 1174854 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf286acc8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 0xffbf9f24 01 [1] 1174855 7 astore_1 0xffbf9f24 01 [1] 1174856 8 iload_0 0xffbf9f24 01 [1] 1174857 9 iconst_1 0xffbf9f24 01 [1] 1174858 10 iadd 0xffbf9f24 01 [1] 1174859 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf286b218) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 0xffbf9e9c 01 [1] 1174860 7 astore_1 0xffbf9e9c 01 [1] 1174861 8 iload_0 0xffbf9e9c 01 [1] 1174862 9 iconst_1 0xffbf9e9c 01 [1] 1174863 10 iadd 0xffbf9e9c 01 [1] 1174864 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf286b708) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 0xffbf9e14 01 [1] 1174865 7 astore_1 0xffbf9e14 01 [1] 1174866 8 iload_0 0xffbf9e14 01 [1] 1174867 9 iconst_1 0xffbf9e14 01 [1] 1174868 10 iadd 0xffbf9e14 01 [1] 1174869 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf286bbf8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 ... 0xffbf76c4 01 [1] 1175239 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf2887fd8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 0xffbf763c 01 [1] 1175240 7 astore_1 0xffbf763c 01 [1] 1175241 8 iload_0 0xffbf763c 01 [1] 1175242 9 iconst_1 0xffbf763c 01 [1] 1175243 10 iadd 0xffbf763c 01 [1] 1175244 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf28886b8) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 0xffbf75b4 01 [1] 1175245 7 astore_1 0xffbf75b4 01 [1] 1175246 8 iload_0 0xffbf75b4 01 [1] 1175247 9 iconst_1 0xffbf75b4 01 [1] 1175248 10 iadd 0xffbf75b4 01 [1] 1175249 11 invokestatic 3 Exception <a 'java/lang/StackOverflowError'> (0xf2888d98) thrown in interpreter method <{method} 'recurse_and_fail' '(I)V' in 'StackTest25'> at bci 0 for thread 0x0003c1a8 SEGV in JVM_handle_solaris_signal [1] static void StackTest25.recurse_and_throw(jint) // recurse 3 times before throw [1] 1157537 0 iload_0 [1] 1157538 1 invokestatic 6 [1] 1157539 0 iload_0 [1] 1157540 1 invokestatic 6 [1] 1157541 0 iload_0 [1] 1157542 1 invokestatic 6 [1] static void StackTest25.recurse_and_fail(jint) [1] 1157543 7 astore_1 [1] 1157544 8 iload_0 [1] 1157545 9 iconst_1 [1] 1157546 10 iadd [1] 1157547 11 invokestatic 3 [1] 1157548 0 iload_0 [1] 1157549 1 invokestatic 6 [1] static void StackTest25.recurse_and_throw(jint) // recurse 2 times before throw [1] 1157550 0 iload_0 [1] 1157551 1 invokestatic 6 [1] 1157552 0 iload_0 [1] 1157553 1 invokestatic 6 [1] static void StackTest25.recurse_and_fail(jint) [1] 1157554 7 astore_1 [1] 11575
11-06-2004

EVALUATION 55 8 iload_0 [1] 1157556 9 iconst_1 [1] 1157557 10 iadd [1] 1157558 11 invokestatic 3 [1] 1157559 0 iload_0 [1] 1157560 1 invokestatic 6 [1] static void StackTest25.recurse_and_throw(jint) // recurse 1 times before throw [1] 1157561 0 iload_0 [1] 1157562 1 invokestatic 6 [1] static void StackTest25.recurse_and_fail(jint) // stack pages must be unguarded %%%%% [1] 1157563 7 astore_1 [1] 1157564 8 iload_0 [1] 1157565 9 iconst_1 [1] 1157566 10 iadd [1] 1157567 11 invokestatic 3 [1] 1157568 7 astore_1 [1] 1157569 8 iload_0 [1] 1157570 9 iconst_1 [1] 1157571 10 iadd [1] 1157572 11 invokestatic 3 [1] 1157573 7 astore_1 [1] 1157574 8 iload_0 [1] 1157575 9 iconst_1 [1] 1157576 10 iadd [1] 1157577 11 invokestatic 3 [1] 1157578 7 astore_1 [1] 1157579 8 iload_0 [1] 1157580 9 iconst_1 [1] 1157581 10 iadd [1] 1157582 11 invokestatic 3 [1] 1157583 7 astore_1 ... SEGV
11-06-2004