JDK-8209139 : globalCounter bootstrap issue
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-08-08
  • Updated: 2018-11-15
  • Resolved: 2018-11-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 12
12 b20Fixed
Related Reports
Relates :  
Description
Followup to JDK-8195100 from Kim Barrett's feedback:

src/hotspot/share/utilities/globalCounter.cpp
64   // Handle bootstrap
65   if (Threads::number_of_threads() == 0) {
66     return;
67   }

What is this about?  number_of_threads only refers to Java threads,
but the iteration should deal with there being none, right?  Or does
this get called so early (because of SymbolTable changes) that even
that iteration setup doesn't work?

If not that, then maybe we're calling before the VMThread exists, and
that's the real problem?  In which case a different test, differently
located, seems necessary.

We needed it when I was bringing up the code and I tried removing it to see whether we still need it and it seems that we do (details on the crash in the bug itself). Maybe Robbin can shed more light here?

The problem here is that we're using the StringTable (and therefore
GlobalCounter) before the main thread has been registered.  That
registration happens in create_vm() (Threads::add(main_thread), line
3729), which follows the call to init_globals() (where the symbol
table usage is occurring) in create_vm().

Maybe moving the Threads::add earlier would fix the problem?  But this
initialization code is very ordering sensitive, so I don't know if
that would work.

Comments
Copying failure details from JDK-8195100 comment: Note, without void GlobalCounter::write_synchronize() { assert((*Thread::current()->get_rcu_counter() & COUNTER_ACTIVE) == 0x0, "must be outside a critcal section"); // Atomic::add must provide fence since we have storeload dependency. volatile uintx gbl_cnt = Atomic::add((uintx)COUNTER_INCREMENT, &_global_counter._counter, memory_order_conservative); + // Handle bootstrap + if (Threads::number_of_threads() == 0) { + return; + } + // Do all RCU threads. CounterThreadCheck ctc(gbl_cnt); for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { ctc.do_thread(thread); } we get: jib > # Internal Error (/scratch/mesos/slaves/c29d9578-9608-44e5-8e00-6c504a81f8a3-S889/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/5b3b9fa6-574d-4449-95da-14f1c0fbf0e4/runs/440a964e-2936-4785-9b28-d4fb67e38b18/workspace/open/src/hotspot/share/runtime/threadSMR.cpp:544), pid=89512, tid=9731 jib > # assert(cl.found() || _thread == VM_Exit::shutdown_thread()) failed: Acquired a ThreadsList snapshot from a thread not recognized by the Thread-SMR protocol. Current thread (0x00007faac0000800): JavaThread "Unknown thread" [_thread_in_vm, id=9731, stack(0x000000010ffd9000,0x00000001100d9000)] _threads_hazard_ptr=0x00007faabd605f60, _nested_threads_hazard_ptr_cnt=0 Stack: [0x000000010ffd9000,0x00000001100d9000], sp=0x00000001100d6890, free space=1014k Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.dylib+0xc5a475] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x609 V [libjvm.dylib+0xc5ab2d] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x47 V [libjvm.dylib+0x45b2df] report_vm_error(char const*, int, char const*, char const*, ...)+0xcc V [libjvm.dylib+0xbdd7f7] SafeThreadsListPtr::verify_hazard_ptr_scanned()+0xcd V [libjvm.dylib+0xbde08a] ThreadsListHandle::ThreadsListHandle(Thread*)+0x38 V [libjvm.dylib+0x5d8bed] GlobalCounter::write_synchronize()+0x137 V [libjvm.dylib+0xb85e67] void ConcurrentHashTable<Symbol*, SymbolTableConfig, (MemoryType)9>::delete_in_bucket<SymbolTableLookup>(Thread*, ConcurrentHashTable<Symbol*, SymbolTableConfig, (MemoryType)9>::Bucket*, SymbolTableLookup&)+0xf3 V [libjvm.dylib+0xb85a06] bool ConcurrentHashTable<Symbol*, SymbolTableConfig, (MemoryType)9>::internal_insert<SymbolTableLookup, SymbolTableCreateEntry, SymbolTableCreateEntry>(Thread*, SymbolTableLookup&, SymbolTableCreateEntry&, SymbolTableCreateEntry&, bool*, bool*)+0x20a V [libjvm.dylib+0xb82632] SymbolTable::do_add_if_needed(char const*, int, unsigned long, bool, Thread*)+0x7e V [libjvm.dylib+0xb82545] SymbolTable::lookup(char const*, int, Thread*)+0xf3 V [libjvm.dylib+0x9cd760] MethodMatcher::parse_method_pattern(char*&, char const*&, MethodMatcher*)+0x448 V [libjvm.dylib+0x9cdb13] BasicMatcher::parse_method_pattern(char*, char const*&)+0xa3 V [libjvm.dylib+0x3ee59d] CompilerOracle::parse_from_line(char*)+0x4b7 V [libjvm.dylib+0x3ef257] CompilerOracle::parse_from_string(char const*, void (*)(char*))+0x4b V [libjvm.dylib+0x3ef4a1] compilerOracle_init()+0x1a V [libjvm.dylib+0x62bae5] init_globals()+0xe5 V [libjvm.dylib+0xbd7fd6] Threads::create_vm(JavaVMInitArgs*, bool*)+0x26a V [libjvm.dylib+0x707dcf] JNI_CreateJavaVM+0xac C [java+0x3c79] JavaMain+0x10b C [libsystem_pthread.dylib+0x3661] _pthread_body+0x154 C [libsystem_pthread.dylib+0x350d] _pthread_body+0x0 C [libsystem_pthread.dylib+0x2bf9] thread_start+0xd --------------- P R O C E S S --------------- Threads class SMR info: _java_thread_list=0x00007faabd605f60, length=0, elements={ } _java_thread_list_alloc_cnt=1, _java_thread_list_free_cnt=0, _java_thread_list_max=0, _nested_thread_list_max=0 _delete_lock_wait_cnt=0, _delete_lock_wait_max=0 _to_delete_list_cnt=0, _to_delete_list_max=0 Java Threads: ( => current thread ) Other Threads: 0x00007faabf013800 GCTaskThread "GC Thread#0" [stack: 0x000070000fc36000,0x000070000fd36000] [id=20995] 0x00007faac0012000 ConcurrentGCThread "G1 Main Marker" [stack: 0x000070000fd39000,0x000070000fe39000] [id=20483] 0x00007faabe801800 ConcurrentGCThread "G1 Conc#0" [stack: 0x000070000fe3c000,0x000070000ff3c000] [id=12291] 0x00007faabf040800 ConcurrentGCThread "G1 Refine#0" [stack: 0x000070000ff3f000,0x000070001003f000] [id=12547] 0x00007faac001b000 ConcurrentGCThread "G1 Young RemSet Sampling" [stack: 0x0000700010042000,0x0000700010142000] [id=13059] =>0x00007faac0000800 (exited) JavaThread "Unknown thread" [_thread_in_vm, id=9731, stack(0x000000010ffd9000,0x00000001100d9000)] _threads_hazard_ptr=0x00007faabd605f60, _nested_threads_hazard_ptr_cnt=0 Threads with active compile tasks: VM state:not at safepoint (not fully initialized) VM Mutex/Monitor currently owned by a thread: None
21-08-2018