Skip to content

Commit

Permalink
Error if invokeinterface receiver is reference array
Browse files Browse the repository at this point in the history
Throw an error during bytecode verification if the receiver
of invokeinterface is a reference array

Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Jul 23, 2024
1 parent dd01de1 commit 1c349ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions runtime/bcverify/rtverify.c
Original file line number Diff line number Diff line change
Expand Up @@ -1775,14 +1775,14 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
goto _inconsistentStack2;
}
} else {
/* Need to ensure that there is at least an Object reference on the stack for the
* invokeinterface receiver. If the top of stack is a base type or TOP, then
* throw a verify error. The check for the receiver to be an interface occurs in
* the invokeinterface bytecode.
* Note: we need to check whether the Object reference on the stack is initialized
* so as to stop an uninitialized object from being addressed here by invokeinterface.
/* Throw a verify error for any of the following invokeinterface scenarios:
* 1. The top of the stack holds a base type or TOP
* 2. The top of the stack holds an object array
* 3. The Object reference on the stack is uninitialized
* The check for the receiver to be an interface occurs in the bytecode interpreter.
*/
if ((BCV_TAG_BASE_TYPE_OR_TOP == (type & BCV_TAG_MASK))
|| ((BCV_OBJECT_OR_ARRAY == (type & BCV_TAG_MASK)) && ((type & BCV_ARITY_MASK) > 0))
|| J9_ARE_ANY_BITS_SET(type, BCV_SPECIAL)
) {
errorType = J9NLS_BCV_ERR_RECEIVER_NOT_COMPATIBLE__ID;
Expand Down
8 changes: 4 additions & 4 deletions runtime/oti/bytecodewalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
32bit type => [8 bits arity] [ 19 bits class index] [5 tag bits]
tag bits:
special (new / init / ret)
base / object
base type array / regular object, array
null
base type or top of stack (clear bit means object or array)
base type array or null
special init object ("this" for <init>)
special new object (PC offset in upper 28 bits)
base types: (in the 19bit class index field)
int
Expand Down

0 comments on commit 1c349ba

Please sign in to comment.