[jboss-jira] [JBoss JIRA] Created: (JASSIST-98) javassist appears to be iinstalling invalid local variable tables

Andrew Dinn (JIRA) jira-events at lists.jboss.org
Thu Nov 12 03:40:05 EST 2009


javassist appears to be iinstalling invalid local variable tables
-----------------------------------------------------------------

                 Key: JASSIST-98
                 URL: https://jira.jboss.org/jira/browse/JASSIST-98
             Project: Javassist
          Issue Type: Bug
            Reporter: Andrew Dinn
            Assignee: Shigeru Chiba


The problem manifested when using the Byteman runtime agent to transform a class which has already been transformed offline using AOP.  It appears that the code generated by AOP using javassist.has an invalid entry in the local variable table. When it is retransfromed (by vanilla ObjectWeb ASM code) the error is compounded resulting in a load exception on the class.

The code which causes the problem is in the JBoss Messaging code in jboss-messaging.jar version 1.4.1.GA (or so the AS component matrix says). The method name is
org$jboss$jms$client$delegate$ClientClusteredConnectionFactoryDelegate$getClientAOPStack$aop()

The relevant section of the decompiled code is as follows:

public synchronized byte[] org$jboss$jms$client$delegate$ClientClusteredConnectionFactoryDelegate$getClientAOPStack$aop()   throws javax.jms.JMSException;
  Code:
   Stack=3, Locals=3, Args_size=1
   0:    getstatic    #397; //Field org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.log:Lorg/jboss/logging/Logger;
   3:    new    #71; //class java/lang/StringBuilder
  . . .
   77:    invokevirtual    #434; //Method org/jboss/logging/Logger.trace:(Ljava/lang/Object;)V
   80:    aload_2
   81:    invokeinterface    #438,  1; //InterfaceMethod org/jboss/jms/delegate/ConnectionFactoryDelegate.getClientAOPStack:()[B
   86:    areturn
   87:    astore_2
   88:    getstatic    #440; //Field org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.log:Lorg/jboss/logging/Logger; 
  . . .
  LocalVariableTable:
   Start  Length  Slot  Name   Signature
   52      32      2    aopStackProvider Lorg/jboss/jms/delegate/ConnectionFactoryDelegate;
   85      31      2    e Lorg/jboss/jms/exception/MessagingNetworkFailureException;
   36      86      1    server       I
   0      132      0    this Lorg/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate;

  Exceptions:
   throws javax.jms.JMSException  Synthetic: true

The entry for aopStackProvider has a valid start position but the length value places its end at position 84 which is not an instruction boundary. It probably ought to add up to 87 i.e.the instruction after the return since the variable will probably be in scope up to and including the return.

The entry for e has an invalid start and end position. First, it is not an instruction boundary. Second, it tarverses a return instruction.

The compounded error manifests as follows during subsequent transformation. When the ASM code transforms this class the reader generates labels for the start and end positions and later visits them as it traverses the input bytecode. However, it only visits labels whose index matches aninstruction boundary. So the invalid entries end up with offset 0. When the transformed code is output the table looks like:

  LocalVariableTable:
   Start  Length  Slot  Name   Signature
   52     -52      2    aopStackProvider Lorg/jboss/jms/delegate/ConnectionFactoryDelegate;
    0        0       2    e Lorg/jboss/jms/exception/MessagingNetworkFailureException;
   36     -36      1    server       I
   0       0      0    this Lorg/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate;

The length for aopStackProvider is calculated as end - start i.e. 0 - 52. This negative length is detected by the JVM and the load for the class  throws an exception.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list