Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert-annotations-to-source may raise an exception depending on the class name #110

Open
pbsf opened this issue Dec 18, 2015 · 10 comments
Open
Labels
Milestone

Comments

@pbsf
Copy link
Contributor

pbsf commented Dec 18, 2015

Below I have two pairs of .jaif/.java files with similar content (almost empty).

MultiVersionControl.jaif:
package plume:
class MultiVersionControl:

MultiVersionControl.java:
package plume;
public class MultiVersionControl { }

MultiVersionControl2.jaif:
package plume:
class MultiVersionControl2:

MultiVersionControl2.java:
package plume;
public class MultiVersionControl2 { }

Even tough they have similar content, when trying to run the insert-annotations-to-source on both pairs only one of them succeed. On the other, I get an exception. Below is the log:

$ insert-annotations-to-source MultiVersionControl2.jaif MultiVersionControl2.java
Warning: IndexFileSpecification did not find classfile for: plume.MultiVersionControl2

$ insert-annotations-to-source MultiVersionControl.jaif MultiVersionControl.java
IndexFileSpecification had a problem reading class: plume.MultiVersionControl
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 758435786
at org.objectweb.asm.ClassReader.readInt(ClassReader.java:2003)
at annotations.io.classfile.CodeOffsetAdapter$1.readInt(CodeOffsetAdapter.java:90)
at annotations.io.classfile.CodeOffsetAdapter$1.visitTableSwitchInsn(CodeOffsetAdapter.java:180)
at annotator.scanner.MethodOffsetClassVisitor$MethodOffsetMethodVisitor.visitTableSwitchInsn(MethodOffsetClassVisitor.java:204)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:1249)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:445)
at annotator.specification.IndexFileSpecification.parseClass(IndexFileSpecification.java:175)
at annotator.specification.IndexFileSpecification.parseScene(IndexFileSpecification.java:150)
at annotator.specification.IndexFileSpecification.parse(IndexFileSpecification.java:103)
at annotator.Main.main(Main.java:566)

I'm attaching the files to make it easier to reproduce.
bug.zip

It might have to do with the fact that AFU uses plume-lib, and the plume-lib project has a plume.MultiVersionControl class. On the other hand, the bug does not arise on other classes from the plume-lib project.

@dbrosoft dbrosoft added the bug label Dec 18, 2015
@dbrosoft dbrosoft self-assigned this Dec 18, 2015
@dbrosoft
Copy link
Contributor

The difference is due to plume.MultiVersionControl being on the classpath (in plume.jar) while plume.MultiVersionControl2 is not. If the latter is available, the same exception is thrown. The pending ASM 5.0 update may or may not fix the problem.

@pbsf
Copy link
Contributor Author

pbsf commented Dec 18, 2015

I also ran insert-annotations-to-source for other files that are in the plume.jar classpath and had no issues. For example, I created the same empty .jaif/.java files with package plume and class name Option and had no issues. plume.Option is on the plume.jar.
I'm attaching this case here too.
Option.zip

Why is it different for the plume.MultiVersionControl?

@dbrosoft
Copy link
Contributor

The underlying cause of the crash is a bug in annotations.io.classfile.CodeOffsetAdapter (in scene-lib). The bug doesn't show up on visiting your empty class, but it does show up on visiting the class of the same name in plume-lib -- which obviously isn't the one you want to visit, so fixing that bug won't fix your problem.

I do have a workaround for you that I don't want to commit because it's not a foolproof solution: Edit annotation-file-utilities/scripts/insert-annotations-to-source and change the argument of -classpath in the last line to .:${CLASSPATH}:${ANNOTATION_FILE_UTILS}, thus putting your plume.MultiVersionControl ahead of the one in plume-lib.

@pbsf
Copy link
Contributor Author

pbsf commented Dec 21, 2015

Thanks for looking into that Dan, but unfortunately this workaround did not work on my environment -- I changed the last line of the script but the exception is still thrown when running this script for plume.MultiVersionControl.

@dbrosoft
Copy link
Contributor

Is it the same code (modulo annotations) as the library version? If so,
that makes sense, and I'll definitely need to fix the underlying bug to
unblock you. If not, would you please send me the source and class files?

-- Dan.

On Mon, Dec 21, 2015 at 9:01 AM, Paulo Barros notifications@github.com
wrote:

Thanks for looking into that Dan, but unfortunately this workaround did
not work on my environment -- I changed the last line of the script but the
exception is still thrown when running this script for
plume.MultiVersionControl.


Reply to this email directly or view it on GitHub
#110 (comment)
.

@pbsf
Copy link
Contributor Author

pbsf commented Dec 21, 2015

Even after modifying the insert-annotations-to-source script like you advised, the file attached on the first message of this thread (bug.zip) still throws an exception when I try to run:

$ insert-annotations-to-source MultiVersionControl.jaif MultiVersionControl.java

@dbrosoft
Copy link
Contributor

Do you have plume-lib in your CLASSPATH already? If so, ensure it's not in
the CLASSPATH and try again.

-- Dan.

On Mon, Dec 21, 2015 at 11:45 AM, Paulo Barros notifications@github.com
wrote:

Even after modifying the insert-annotations-to-source script like you
advised, the file attached on the first message of this thread (bug.zip)
still throws an exception when I try to run:

$ insert-annotations-to-source MultiVersionControl.jaif
MultiVersionControl.java


Reply to this email directly or view it on GitHub
#110 (comment)
.

@pbsf
Copy link
Contributor Author

pbsf commented Dec 21, 2015

plume-lib was indeed on my CLASSPATH. I removed it but the error remains:

$ echo $CLASSPATH

$ insert-annotations-to-source MultiVersionControl.java MultiVersionControl.jaif
IndexFileSpecification had a problem reading class: plume.MultiVersionControl
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2146924934
at org.objectweb.asm.ClassReader.readInt(ClassReader.java:2003)
...

@dbrosoft
Copy link
Contributor

I've fixed the bug that causes the crash, but I'm leaving this issue open until I have implemented a way to distinguish the analysis classpath from the runtime classpath.

@mernst mernst added this to the Low milestone Jan 10, 2016
@pbsf
Copy link
Contributor Author

pbsf commented Jan 18, 2016

This has also been fixed on my environment since Dan's last message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants