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

Fix the crash issue with the error message framework in Verifier #15681

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion runtime/verbose/errormessagehelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,27 @@ decodeConstuctedStackMapFrameData(StackMapFrame* stackMapFrame, U_8* nextStackma
VerificationTypeInfo* currentVerificationTypeEntry = stackMapFrame->entries;
U_16 maxStack = methodInfo->maxStack;
U_16 maxLocals = methodInfo->maxLocals;
IDATA lastIndex = stackBaseIndex - 1;
/* The layout of 'locals' and 'stack' in each stackmap frame of a constructed stackmaps looks as follows:
* +-----------------------+------------------+
* | locals | stack |
* +-----------------------+------------------+
* 0 | |
* lastIndex stackBaseIndex
* It shows that stackBaseIndex points to the 1st element of 'stack' while lastIndex points to
* the last element of 'locals'.
*
* Initially, both stackBaseIndex and stackTopIndex are set to -1 by default before the stackmaps
* are constructed internally against the class bytecode (class version <= 50) via simulateStack(),
* in which case both 'locals' and 'stack' are empty in each stackmap frame of the stackmaps.
* (See the code of initializing stackmaps in j9bcv_verifyBytecodes() at bcverify.c)
*
* Thus, there are 3 cases in terms of a given stackmap frame of the constructed stackmaps:
* 1)if stackBaseIndex == -1(which means that both 'locals' and 'stack' are empty), lastIndex is -1.
* 2)if stackBaseIndex == 0 (which means that there is 1 element in 'locals'), lastIndex is 0.
* 3)if stackBaseIndex >= 1 (which means that there is at least 1 element in 'locals'),
* lastIndex is (stackBaseIndex - 1).
*/
IDATA lastIndex = (stackBaseIndex >= 1) ? (stackBaseIndex - 1) : stackBaseIndex;
IDATA slot = 0;
IDATA dataTypeCode = DATATYPE_1_SLOT;
BOOLEAN nonTopFound = FALSE;
Expand Down Expand Up @@ -807,6 +827,7 @@ releaseVerificationTypeBuffer(StackMapFrame* stackMapFrame, MethodContextInfo* m
if (NULL != stackMapFrame->entries) {
PORT_ACCESS_FROM_PORT(methodInfo->portLib);
j9mem_free_memory(stackMapFrame->entries);
stackMapFrame->entries = NULL;
}
}

Expand Down