JDK-8055236 : Deadlock during NMT2 shutdown on Windows
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2014-08-15
  • Updated: 2015-06-03
  • Resolved: 2014-08-21
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 8 JDK 9
8u40Fixed 9 b30Fixed
Description
00 00eaf08c 76243bc8 ntdll_77940000!ZwDelayExecution+0x15
01 00eaf0f4 76244498 KERNELBASE!SleepEx+0x65
02 00eaf104 702881eb KERNELBASE!Sleep+0xf
03 00eaf114 702436fa jvm!os::naked_short_sleep+0x3b [c:\jprt\t\p1\172400.zhgu\s\src\os\windows\vm\os_windows.cpp @ 3500]
04 00eaf138 702437a3 jvm!MallocSiteTable::AccessLock::exclusiveLock+0xaa [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\services\mallocsitetable.cpp @ 253]
05 00eaf154 70244175 jvm!MallocSiteTable::shutdown+0x23 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\services\mallocsitetable.cpp @ 223]
06 00eaf164 7025677f jvm!MallocTracker::transition+0xb5 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\services\malloctracker.cpp @ 128]
07 00eaf184 70256894 jvm!MemTracker::transition_to+0x4f [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\services\memtracker.cpp @ 167]
08 00eaf18c 70286b46 jvm!MemTracker::shutdown+0x34 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\services\memtracker.cpp @ 151]
09 00eaf194 7044cc54 jvm!DllMain+0x46 [c:\jprt\t\p1\172400.zhgu\s\src\os\windows\vm\os_windows.cpp @ 147]
0a 00eaf1d8 7044cd0e jvm!__DllMainCRTStartup+0x7a [f:\dd\vctools\crt_bld\self_x86\crt\src\crtdll.c @ 512]
0b 00eaf1e4 779799a0 jvm!_DllMainCRTStartup+0x1e [f:\dd\vctools\crt_bld\self_x86\crt\src\crtdll.c @ 476]
0c 00eaf204 7798d6ba ntdll_77940000!LdrpCallInitRoutine+0x14
0d 00eaf2a8 7798d55c ntdll_77940000!LdrShutdownProcess+0x1aa
0e 00eaf2bc 75e17362 ntdll_77940000!RtlExitUserProcess+0x74
0f 00eaf2d0 7c348d03 kernel32!ExitProcessStub+0x12
10 00eaf2d8 7c3476c8 MSVCR71!__crtExitProcess+0x2e [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 463]
11 00eaf308 7c348d11 MSVCR71!doexit+0xab [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 414]
12 00eaf318 1000348a MSVCR71!exit+0xd [f:\vs70builds\3052\vc\crtbld\crt\src\crt0dat.c @ 303]
WARNING: Stack unwind information not available. Following frames may be wrong.
13 00eaf3dc 701f1a32 ap01t001!Agent_OnAttach+0x9a
14 00eaf41c 7015f39c jvm!before_exit+0x212 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\runtime\java.cpp @ 522]
15 00eaf430 740150e3 jvm!JVM_Halt+0xfc [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\prims\jvm.cpp @ 430]
16 00eaf558 701f28da java_74010000!Java_java_lang_Shutdown_halt0+0x9
17 00eaf5ec 7030ec52 jvm!JavaCalls::call_helper+0x3ea [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\runtime\javacalls.cpp @ 407]
18 00eaf634 701f2998 jvm!os::os_exception_wrapper+0xa2 [c:\jprt\t\p1\172400.zhgu\s\src\os_cpu\windows_x86\vm\os_windows_x86.cpp @ 114]
19 00eaf654 7012f2d9 jvm!JavaCalls::call+0x48 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\runtime\javacalls.cpp @ 308]
1a 00eaf734 70141969 jvm!jni_invoke_static+0x1b9 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\prims\jni.cpp @ 1100]
1b 00eaf7a0 012c22fc jvm!jni_CallStaticVoidMethod+0x259 [c:\jprt\t\p1\172400.zhgu\s\src\share\vm\prims\jni.cpp @ 1981]
1c 00eaf7ec 012cae08 java+0x22fc
1d 00eaf824 012cae92 java+0xae08
1e 00eaf830 75e13677 java+0xae92
1f 00eaf83c 77979f42 kernel32!BaseThreadInitThunk+0xe
20 00eaf87c 77979f15 ntdll_77940000!__RtlUserThreadStart+0x70
21 00eaf894 00000000 ntdll_77940000!_RtlUserThreadStart+0x1b

Comments
The problem is caused by acquiring locks inside MemTracker::shutdown(), which could be held by threads that have been already killed. Given the MemTracker::shutdown() call is on JVM exiting path, the call is not necessary, should be removed. NMT1 does not have this problem, as MemTracker::shutdown() in NMT1 only sets shutdown pending flag, no lock is taken. Upon seeing the pending flag, NMT worker thread does the real shutdown cleanup.
20-08-2014