[jboss-jira] [JBoss JIRA] Commented: (JASSIST-98) javassist appears to be iinstalling invalid local variable tables
Andrew Dinn (JIRA)
jira-events at lists.jboss.org
Thu Nov 12 07:28:05 EST 2009
[ https://jira.jboss.org/jira/browse/JASSIST-98?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12494310#action_12494310 ]
Andrew Dinn commented on JASSIST-98:
------------------------------------
I believe the bug is in class LocalVariableAttribute method shiftPc. The code is as follows:
void shiftPc(int where, int gapLength, boolean exclusive) {
int n = tableLength();
for (int i = 0; i < n; ++i) {
int pos = i * 10 + 2;
int pc = ByteArray.readU16bit(info, pos);
int len = ByteArray.readU16bit(info, pos + 2);
/* if pc == 0, then the local variable is a method parameter.
*/
if (pc > where || (exclusive && pc == where && pc != 0))
ByteArray.write16bit(pc + gapLength, info, pos);
else if (pc + len > where)
ByteArray.write16bit(len + gapLength, info, pos + 2);
}
}
The else clause should actually be
else if (pc + len > where || (exclusive && pc + len == where))
ByteArray.write16bit(len + gapLength, info, pos + 2);
}
The code which moves the etable end pc takes account of the case where end == where and the insert is exclusive and looking at the decompiled code I notice that the etable is correct:
Exception table:
from to target type
47 86 87 Class org/jboss/jms/exception/MessagingNetworkFailureException
> 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