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

SIGSEGV instantiating class redefined through Instrumentation.redefineClasses

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.0
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b56
    • CPU:
      sparc
    • OS:
      solaris_9

      Description



      Name: tb29552 Date: 05/26/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      SunOS mary 5.9 Generic_112233-12 sun4u sparc SUNW,Sun-Blade-100

      A DESCRIPTION OF THE PROBLEM :
      SIGSEGV when instantiating a class redefined through java.lang.instrument.Instrumentation.redefineClass()

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile and run the program given with
      java -javaagent:Teste Teste

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The following output is expected:
      Integer
      Button
      ACTUAL -
      Integer
      #
      # An unexpected error has been detected by HotSpot Virtual Machine:
      #
      # SIGSEGV (0xb) at pc=0xfe93b930, pid=27942, tid=6
      #
      # Java VM: Java HotSpot(TM) Server VM (1.5.0-beta-b32c mixed mode)
      # Problematic frame:
      # V [libjvm.so+0x13b930]
      #
      # An error report file with more information is saved as hs_err_pid27942.log
      #
      # If you would like to submit a bug report, please visit:
      # http://java.sun.com/webapps/bugreport/crash.jsp
      #
      Abort


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.instrument.*;
      import java.io.*;

      public class Teste {
          static Instrumentation instrumentation;

          public static void main(String[] args) throws Exception {
              redefine(java.lang.Integer.class);
              new java.lang.Integer(0);
              System.out.println("Integer");
              redefine(java.awt.Button.class);
              new java.awt.Button();
              System.out.println("Button");
          }

          public static void premain(String agentArgs, Instrumentation instr) {
              instrumentation = instr;
          }

          public static void redefine(Class cl) throws Exception {
              ClassLoader cloader = cl.getClassLoader();
              if (cloader == null) {
                  cloader = ClassLoader.getSystemClassLoader();
              }
              String className = cl.getName().replace('.', '/') + ".class";
              InputStream is = cloader.getResourceAsStream(className);
              if (is == null) throw new RuntimeException();
              ByteArrayOutputStream bo = new ByteArrayOutputStream();
              for(int n = is.read(); n != -1; n = is.read()) {
                  bo.write(n);
              }
              instrumentation.redefineClasses(new ClassDefinition[] {
                    new ClassDefinition(cl, bo.toByteArray()) });
          }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 275122)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                swamyv Swamy Venkataramanappa
                Reporter:
                tbell Tim Bell
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: