Skip to content

Commit d24c9fc

Browse files
authored
Merge pull request #19931 from theresa-m/fix_19756_47
0.47: Error if invokeinterface receiver is reference array
2 parents 464125c + 8e11981 commit d24c9fc

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

runtime/bcverify/rtverify.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,14 +1775,15 @@ verifyBytecodes (J9BytecodeVerificationData * verifyData)
17751775
goto _inconsistentStack2;
17761776
}
17771777
} else {
1778-
/* Need to ensure that there is at least an Object reference on the stack for the
1779-
* invokeinterface receiver. If the top of stack is a base type or TOP, then
1780-
* throw a verify error. The check for the receiver to be an interface occurs in
1781-
* the invokeinterface bytecode.
1782-
* Note: we need to check whether the Object reference on the stack is initialized
1783-
* so as to stop an uninitialized object from being addressed here by invokeinterface.
1778+
/* Throw a verify error for any of the following invokeinterface scenarios:
1779+
* 1. The top of the stack holds a base type or TOP
1780+
* 2. The top of the stack holds an array. Null type has a different meaning for arity bits.
1781+
* Don't fail at this point, a NullPointerException is expected later on.
1782+
* 3. The Object reference on the stack is uninitialized
1783+
* The check for the receiver to be an interface occurs in the bytecode interpreter.
17841784
*/
17851785
if ((BCV_TAG_BASE_TYPE_OR_TOP == (type & BCV_TAG_MASK))
1786+
|| ((type != BCV_BASE_TYPE_NULL) && (BCV_ARITY_FROM_TYPE(type) > 0))
17861787
|| J9_ARE_ANY_BITS_SET(type, BCV_SPECIAL)
17871788
) {
17881789
errorType = J9NLS_BCV_ERR_RECEIVER_NOT_COMPATIBLE__ID;

runtime/oti/bytecodewalk.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
32bit type => [8 bits arity] [ 19 bits class index] [5 tag bits]
6262
6363
tag bits:
64-
special (new / init / ret)
65-
base / object
66-
base type array / regular object, array
67-
null
64+
base type or top of stack (clear bit means object or array)
65+
base type array or null
66+
special init object ("this" for <init>)
67+
special new object (PC offset in upper 28 bits)
6868
6969
base types: (in the 19bit class index field)
7070
int

0 commit comments

Comments
 (0)