JDK-8146222 : assert(_initialized) failed: TLS not initialized yet!
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2015-12-27
  • Updated: 2016-02-11
  • Resolved: 2016-01-11
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 9
9 b105Fixed
Related Reports
Relates :  
Description
JDK-8144947 showed an error path where we can call Thread::current_or_null before TLS has been initialized and so hit the assertion failure:

00 0261eeac 6d9226d7 jvm!VMError::report_and_die+0x870 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\utilities\vmerror.cpp @ 1304]
01 0261eee0 6d605ae8 jvm!VMError::report_and_die+0x27 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\utilities\vmerror.cpp @ 1083]
02 0261ef00 6d8fb03f jvm!report_vm_error+0x48 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\utilities\debug.cpp @ 218]
03 0261ef14 6d8477de jvm!ThreadLocalStorage::thread+0x1f [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\os\windows\vm\threadlocalstorage_windows.cpp @ 52]
04 (Inline) -------- jvm!Thread::current_or_null_safe+0x5
05 0261f06c 6d724e78 jvm!topLevelExceptionFilter+0x3e [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\os\windows\vm\os_windows.cpp @ 2357]
06 0261f074 6dcb2aa5 jvm!JNI_CreateJavaVM+0x78 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\prims\jni.cpp @ 4107]
07 0261f088 6dcb2b33 msvcr120!_EH4_CallFilterFunc+0x12 [f:\dd\vctools\crt\crtw32\misc\i386\exsup4.asm @ 391]
08 0261f0b4 6d947682 msvcr120!_except_handler4_common+0x8e [f:\dd\vctools\crt\crtw32\misc\i386\chandler4.c @ 360]
09 0261f0d4 76fd00b1 jvm!_except_handler4+0x1e [f:\dd\vctools\crt\crtw32\misc\i386\chandler4gs.c @ 91]
0a 0261f0f8 76fd0083 ntdll!ExecuteHandler2+0x26
0b 0261f1c4 76fd07ff ntdll!ExecuteHandler+0x24
0c 0261f1c4 6d698956 ntdll!KiUserExceptionDispatcher+0xf
0d (Inline) -------- jvm!GuardedMemory::Guard::verify+0x9
0e 0261f520 6d83dff8 jvm!GuardedMemory::print_on+0x86 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\memory\guardedmemory.cpp @ 67]
0f 0261f534 6d83b1bb jvm!verify_memory+0xb8 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\runtime\os.cpp @ 529]
10 0261f574 6d48bb5b jvm!os::free+0x7b [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\runtime\os.cpp @ 692]
11 0261f584 6d48eb49 jvm!ScopedVMInitArgs::~ScopedVMInitArgs+0x2b [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\runtime\arguments.cpp @ 3551]
12 0261f5dc 6d8f2f24 jvm!Arguments::parse+0x279 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\runtime\arguments.cpp @ 4125]
13 0261f6b0 6d722a6f jvm!Threads::create_vm+0x94 [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\runtime\thread.cpp @ 3418]
14 0261f714 6d724e4f jvm!JNI_CreateJavaVM_inner+0x6f [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\prims\jni.cpp @ 4016]
15 0261f754 00282551 jvm!JNI_CreateJavaVM+0x4f [c:\jprt\t\p1\232608.cphillim\s\hotspot\src\share\vm\prims\jni.cpp @ 4105] 

Need to see if this can be avoided.
Comments
Simple fix is to move the ThreadLocalStorage::init() prior to any argument parsing code. As it contains simple OS library calls it can be initialized very early. Even the asserts in it still work (somewhat surprisingly) after the move. Failure mode before the fix: Agent[1].stdout: ## nof_mallocs = 674, nof_frees = 38 Agent[1].stdout: ## memory stomp: Agent[1].stdout: GuardedMemory(0x0000000000fbf690) base_addr=0x0000000000fbf3f0 tag=0x00000000000da360 user_size=16512112 user_data=0x0000000000fbf410 Agent[1].stdout: Header guard @0x0000000000fbf3f0 is BROKEN Agent[1].stdout: # To suppress the following error report, specify this argument Agent[1].stdout: # after -XX: or in .hotspotrc: SuppressErrorAt=\threadLocalStorage_windows.cpp:52 Agent[1].stdout: # Agent[1].stdout: # A fatal error has been detected by the Java Runtime Environment: Agent[1].stdout: # Agent[1].stdout: # Internal Error (C:\jprt\T\P1\020042.daholme\s\hotspot\src\os\windows\vm\threadLocalStorage_windows.cpp:52), pid=5076, tid=4348 Agent[1].stdout: # assert(_initialized) failed: TLS not initialized yet! Failure mode after: Agent[1].stdout: ## nof_mallocs = 601, nof_frees = 36 Agent[1].stdout: ## memory stomp: Agent[1].stdout: GuardedMemory(0x00f1fc44) base_addr=0x00f1fb40 tag=0x003a9bc0 user_size=1942466404 user_data=0x00f1fb58 Agent[1].stdout: Header guard @0x00f1fb40 is BROKEN Agent[1].stdout: # Agent[1].stdout: # A fatal error has been detected by the Java Runtime Environment: Agent[1].stdout: # Agent[1].stdout: # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x73bb8ab6, pid=10328, tid=7672
08-01-2016