Open lschuetze opened 7 years ago
Turning the ThreadLocal
from long
to int
results in no error. Now it has to be checked if the error is with this library or ASM. After running in debug mode and debugging DiSL as well as ASM the problem manifests in TLVInserter$TLVInitializer#onMethodEnter()
.
// -- put value to the field --
visitLabel(putValue);
visitFieldInsn(PUTFIELD, THREAD_CLASS_NAME, tlv.getName(), tlv.getTypeAsDesc());
The crash happens then in visitFieldInsns
when there is a 3rd popValue()
triggered. The stack is empty but it tries to remove an element.
case PUTFIELD:
popValue();
popValue();
if (longOrDouble) {
popValue();
}
break;
The bug was in DiSL. The problem was that for long or double values the value has to be put twice on the stack. When stored to the variable it will be popped twice.
However, as initialisation value visitLdcInsn (0);
was called which will be boxed into an Integer. visitLdcInsn
will check if the type is Long or Double and push the value twice. This will never be triggered. The fix is to change the line to the following
final char c = tlv.getTypeAsDesc ().charAt (0);
final boolean longOrDouble = c == 'J' || c == 'D';
// insert 0 as default
if (longOrDouble) {
visitLdcInsn (0L);
} else {
visitLdcInsn (0);
}
Hi,
I wanted to try out DiSL, but I get an
java.lang.ArrayIndexOutOfBoundsException
when exeuting the code.I cloned the repo and built the source code with
ant
. I build my instrumentation code with ant, too. I use Mac OS with Java 1.8.0_111 and GraalVM 0.19 to start withdisl.py
. Using a@SyntheticLocal
variable makes the code run without problems, but as the semantics of SyntheticLocal is defined it is not a persisted value that I can increase from different methods :-)How I call
disl.py
:The stack trace:
The instrumentation code:
Do you know how to fix this issue? I already tried ASM 5.2 (from Dec '16) but this did not solve the error.
Just ping back if you need any further information!