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

Error if invokeinterface receiver is reference array #19877

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

theresa-m
Copy link
Contributor

Throw an error during bytecode verification if the receiver of invokeinterface is a reference array.
Fix: #19756

@tajila
Copy link
Contributor

tajila commented Jul 22, 2024

Did you run verification tests with this change?

@tajila tajila requested a review from ChengJin01 July 22, 2024 18:18
#define BCV_TAG_BASE_ARRAY_OR_NULL 2 /* set bit means base type array */
#define BCV_SPECIAL_INIT 4 /* set bit means special init object ("this" for <init>) */
#define BCV_SPECIAL_NEW 8 /* set bit means special new object (PC offset in upper 28 bits) */
#define BCV_OBJECT_OR_ARRAY 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to leave these comments out there to avoid any confusion/misconception in the future given it's clearer for developers to understand how to use these constants with the comments put aside.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I was thinking it would be good to have one set of comments, but I don't think there's a risk of this code changing significantly :) I'll add them back.

@ChengJin01
Copy link

ChengJin01 commented Jul 22, 2024

Did you run verification tests with this change?

@theresa-m, you will need to run internal & open builds to ensure there is no issue introduced with your changes. In addition, please share with us the output of OpenJ9 with the updated fix as compared to RI.

@theresa-m theresa-m force-pushed the fix_19756 branch 2 times, most recently from 1c349ba to 0893ddc Compare July 23, 2024 15:47
@theresa-m
Copy link
Contributor Author

The output of OpenJ9 for the test provided in the issue is:

Error: Unable to initialize main class TestInterface
Caused by: java.lang.VerifyError: JVMVRFY021 thrown object not throwable; class=TestInterface, method=method1()V, pc=7
Exception Details:
  Location:
    TestInterface.method1()V @7: JBinvokeinterface
  Reason:
    Type '[LTestInterface$A;' (current frame, stack[0]) is not assignable to 'java/lang/Object'
  Current Frame:
    bci: @7
    flags: { }
    locals: { '[LTestInterface$A;' }
    stack: { '[LTestInterface$A;' }

@ChengJin01
Copy link

I will approve the PR once it passes all related internal & open test cases.

@theresa-m
Copy link
Contributor Author

I updated this change after further testing to make sure the type is not BCV_BASE_TYPE_NULL since BCV_BASE_TYPE_NULL has non-zero arity bits.

@ChengJin01
Copy link

I updated this change after further testing to make sure the type is not BCV_BASE_TYPE_NULL since BCV_BASE_TYPE_NULL has non-zero arity bits.

That's correct as a NULL value belongs to reference as per the VM Spec.

Throw an error during bytecode verification if the receiver
of invokeinterface is a reference array

Signed-off-by: Theresa Mammarella <[email protected]>
Copy link

@ChengJin01 ChengJin01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@tajila
Copy link
Contributor

tajila commented Jul 24, 2024

jenkins test sanity alinux64 jdk8,jdk21

@tajila tajila merged commit 876f013 into eclipse-openj9:master Jul 25, 2024
7 checks passed
@tajila
Copy link
Contributor

tajila commented Jul 25, 2024

@theresa-m Please make a 0.47 PR as well

@theresa-m
Copy link
Contributor Author

#19931 is for 0.47

@theresa-m theresa-m deleted the fix_19756 branch October 11, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

J9 verification permits non-interfaces on operand stack of invokeinterface
3 participants