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

Fixed failure when instrumenting classes with an annotation containing an Enum-type value #205

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

katherine-hough
Copy link
Collaborator

Failure Description

Phosphor instrumentation throws an IllegalArgumentException when processing a class containing an annotation with a value of an Enum type.

Stack Trace

java.lang.IllegalArgumentException: value edu.columbia.cs.psl.phosphor.struct.TaggedReferenceArray@770d3326
        at java.base/edu.columbia.cs.psl.phosphor.org.objectweb.asm.SymbolTable.addConstant(SymbolTable.java:525)
        at java.base/edu.columbia.cs.psl.phosphor.org.objectweb.asm.AnnotationWriter.visit(AnnotationWriter.java:259)
        at java.base/edu.columbia.cs.psl.phosphor.org.objectweb.asm.tree.AnnotationNode.accept(AnnotationNode.java:226)
        at java.base/edu.columbia.cs.psl.phosphor.org.objectweb.asm.tree.AnnotationNode.accept(AnnotationNode.java:193)
        at java.base/edu.columbia.cs.psl.phosphor.org.objectweb.asm.tree.MethodNode.accept(MethodNode.java:674)
        at java.base/edu.columbia.cs.psl.phosphor.instrumenter.TaintLoadCoercer$UninstTaintLoadCoercerMN.visitEnd(TaintLoadCoercer.java:235)

Cause

ASM's AnnotationNode class is not instrumented by Phosphor. AnnotationNode uses an instance of the Java Class Library class java.util.ArrayList to store name-value pairs for an annotation. java.util.ArrayList is instrumented by Phosphor. Enum values are stored by AnnotationNode as String arrays. ArrayList will wrap these String arrays into TaggedReferenceArray instances and before storing them. When the AnnotationNode goes to process the Enum value, it receives a TaggedReferenceArray from the ArrayList instead of a String array.

Changes

  • Added previously failing test case demonstrating instrumentation failure when processing annotations containing Enum values.
  • Fixed instrumentation failure when processing annotations containing Enum values by adding a class visitor to PhosphorPatcher to unwrap TaggedReferenceArray instances returned by certain JCL methods in ASM classes.

…ilure when processing annotations containing enum-type values.

* Fixed instrumentation failure when processing annotations containing enum-type values by adding a class visitor to PhosphorPatcher to unwrap TaggedReferenceArrays returned by certain methods in ASM classes instrumentation boundary issues.
@katherine-hough katherine-hough merged commit 972b5e4 into master Nov 23, 2023
7 checks passed
@katherine-hough katherine-hough deleted the annotation-fix branch November 23, 2023 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant