Skip to content

Commit 2fb420e

Browse files
committed
Protect entryName from being collected by the GC
j9gc_createJavaLangString can release VM access, which allows the GC to move or collect objects. To prevent this, entryName is pushed to a special frame before the call to j9gc_createJavaLangString. This ensures that entryName is protected from being moved or collected by the GC. Related: #20870 Signed-off-by: Babneet Singh <[email protected]>
1 parent 9362c83 commit 2fb420e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

runtime/vm/bindnatv.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@ lookupJNINative(J9VMThread *currentThread, J9NativeLibrary *nativeLibrary, J9Met
11101110
if (NULL != entryName) {
11111111
#if JAVA_SPEC_VERSION >= 24
11121112
J9ROMMethod *nativeROMMethod = J9_ROM_METHOD_FROM_RAM_METHOD(nativeMethod);
1113+
PUSH_OBJECT_IN_SPECIAL_FRAME(currentThread, entryName);
11131114
j9object_t javaName = mmFuncs->j9gc_createJavaLangStringWithUTFCache(currentThread, J9ROMMETHOD_NAME(nativeROMMethod));
1115+
entryName = POP_OBJECT_IN_SPECIAL_FRAME(currentThread);
11141116
if (NULL != javaName)
11151117
#endif /* JAVA_SPEC_VERSION >= 24 */
11161118
{

0 commit comments

Comments
 (0)