Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4217960

[native stack overflow bug] reflection test causes crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1, 1.1.6, 1.2.0, 1.3.1, 1.4.0
    • Fix Version/s: None
    • Component/s: hotspot
    • Subcomponent:
    • CPU:
      generic, x86, sparc
    • OS:
      generic, linux, solaris_2.4, solaris_2.5.1, solaris_2.6, windows_95, windows_nt

      Description

      The following program causes JDK1.1.8 and JDK1.2 to crash.

      import java.applet.*;
      import java.lang.Class;
      import java.lang.reflect.*;

      public class Test implements Runnable {

          static int depth = 0;
          static Method m;

          public static void test(Method m) throws Throwable {
              ++depth;
              System.err.println("Test at depth " + depth);

              Object[] args = {m};
              try {
                  m.invoke(null, args);
              } catch (InvocationTargetException e) {
                  throw e.getTargetException();
              }
          }

          public void run() {
              try {
                  Class c = Test.class;
                  Class[] sig = {Method.class};
                  m = c.getMethod("test", sig);
                  test(m);
              } catch (InvocationTargetException e) {
                  System.err.println("InvocationTargetException occurred.");
                  e.printStackTrace();
                  e.getTargetException().printStackTrace();
              } catch (Throwable e) {
                  System.err.println("Exception occurred.");
                  e.printStackTrace();
              }
              System.err.println("depth " + depth);
          }

          public static void main(String[] args) {
              new Thread(new Test()).start();
          }
      }

      It purposely runs in a separate thread so that it gets a new native
      C stack. For Solaris, this is smaller than the main thread's
      stack, so the test crashes quickly without eating up all your
      swap space.

      dean.long@Eng 1999-03-06

      Name: skR10017 Date: 04/21/2000



      The same test crashes linux VM with Segmentation Fault error.
       
      ======================================================================

      Name: krC82822 Date: 07/15/2001


      [1.3.1 and 1.4 beta build 65 on Linux]

      1.) Write some kind of endless indirect recursion (a calls b, b calls a). In my
      case it was a FilterInputStream where read(b[],ofs,len) calls read(b[]).
      2.) Run the program.

      As soon as control flow gets to the point, the JVM crashes with a segmentation
      violation signal. The correct behaviour would be to throw a StackOverflowException.
      I was really confused about the JVM crash and couldn't find the problem.

      IBM's Linux JVM handles the problem correctly and throws a nice stack dump.
      (Review ID: 128094)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              collins Gary Collins (Inactive)
              Reporter:
              dlong Dean Long
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: