Description
Currently GC assumes any j9module should have moduleObject set.
I am trying to add assertions to verify this fact.
During testing I got assertion triggered:
10:58:14 stderr: [14:57:26.824 0x14607d500 j9mm.107 * ** ASSERTION FAILED ** at /Users/jenkins/workspace/Build_JDK21_aarch64_mac_Personal/openj9/runtime/gc_base/RootScanner.cpp:103: ((false && (__null != _javaVM->unnamedModuleForSystemLoader->moduleObject)))
> !j9javavm 0x000000014601D220 | grep unnamedModuleForSystemLoader
0x50a8: struct J9Module* unnamedModuleForSystemLoader = !j9module 0x0000000146073CB0
> !j9module 0x0000000146073CB0
J9Module at 0x146073cb0 {
Fields for J9Module:
0x0: struct J9UTF8* moduleName = !j9utf8 0x0000000000000000
0x8: struct J9Object* moduleObject = !j9object 0x0000000000000000 <-----
0x10: struct J9Object* version = !j9object 0x0000000000000000
0x18: struct J9ClassLoader* classLoader = !j9classloader 0x0000000146072A68
0x20: struct J9HashTable* readAccessHashTable = !j9hashtable 0x0000000000000000
0x28: struct J9HashTable* removeAccessHashTable = !j9hashtable 0x0000000000000000
0x30: struct J9HashTable* removeExportsHashTable = !j9hashtable 0x0000000000000000
0x38: U32 isLoose = 0x00000000 (0)
0x3c: U32 isOpen = 0x00000000 (0)
}
This NULL pointer was discovered early during very first Scavenge.
Current code does not crash because Scavenger slot scanner has NULL check. However there is no guarantee code is NULL guarded. For example scanning during Mark Phase of Global GC does not have such guard. If Global GC will occur early enough (for example with optthruput and small heap) it might lead to crash.
So, ideally we need to prevent GC to occur until moduleObject is set. If there is difficulty with this GC code should be NULL guarded (with potential side effect newly created moduleObject can be collected unexpectedly).
@tajila @JasonFengJ9 Would you please take a look? Code with assertion has not been merged yet and needs to be added for testing.