From fd041c00e65ba6a41f57ec722f27fe08d1f37b17 Mon Sep 17 00:00:00 2001 From: Tobi Ajila Date: Wed, 13 Oct 2021 10:52:54 -0400 Subject: [PATCH] Use correct loop condition when searching for methods As of JDK8 we permitted the addition of methods when redefining classes. This means that between two versions of the same class, the number of methods may not be the same. As a result we can not use the same romMethodCount when iterating ramMethods for different versions of the same class. Signed-off-by: Tobi Ajila --- runtime/vm/exceptiondescribe.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/vm/exceptiondescribe.c b/runtime/vm/exceptiondescribe.c index 943ddfc48c6..6701f663bf7 100644 --- a/runtime/vm/exceptiondescribe.c +++ b/runtime/vm/exceptiondescribe.c @@ -358,7 +358,8 @@ iterateStackTrace(J9VMThread * vmThread, j9object_t* exception, callback_func_t while (NULL != ramClass) { U_32 i = 0; J9Method *methods = ramClass->ramMethods; - for (i = 0; i < romClass->romMethodCount; ++i) { + UDATA romMethodCount = ramClass->romClass->romMethodCount; + for (i = 0; i < romMethodCount; ++i) { J9ROMMethod *possibleMethod = J9_ROM_METHOD_FROM_RAM_METHOD(&methods[i]); /* Note that we cannot use `J9_BYTECODE_START_FROM_ROM_METHOD` here because native method PCs @@ -367,6 +368,7 @@ iterateStackTrace(J9VMThread * vmThread, j9object_t* exception, callback_func_t if ((methodPC >= (UDATA)possibleMethod) && (methodPC < (UDATA)J9_BYTECODE_END_FROM_ROM_METHOD(possibleMethod))) { romMethod = possibleMethod; methodPC -= (UDATA)J9_BYTECODE_START_FROM_ROM_METHOD(romMethod); + romClass = ramClass->romClass; goto foundROMMethod; } }